No displaying a bitmap using WinApi/GDI lazarus / 39-Graphics ---------------------------------------------------------------------- ADMGNS · 2024-08-13 22:43 Hello I am traying to display a bitmap using WinApi/GDI, but no displaying.. C and Pascal source codes are identical (see attachments).. C one works, but pascal one doesn't.. What is the wrong thing?? Thanks ---------------------------------------------------------------------- 440bx · 2024-08-14 00:29 The C version declares some of the variables as "static" which means, the variables retain their value in subsequent calls to the window procedure.  In your Pascal code, the same variables are NOT static, just plain local variables, this causes them to lose their value. Specifically, the value of the bitmap handle obtained in the WM_CREATE is lost when WM_CREATE ends, therefore the WM_PAINT is using some garbage that is occupying the bitmap handle when the WM_PAINT is processed. Solution: ensure the variables declared as "static" in the C code are either global variables in your code or writable type constants (which is what "static" is in FPC.) HTH. ---------------------------------------------------------------------- 440bx · 2024-08-14 00:36 Also, if you're interested in programming directly to the Windows API, the following examples may be useful to you: https://forum.lazarus.freepascal.org/index.php/topic,53791.0.html Among others, there is an example that loads a bitmap and displays it in the window. HTH. ---------------------------------------------------------------------- ADMGNS · 2024-08-14 02:59 thanks for your replies.. SOLVED.