I am using a static control as a bitmap viewer. Whenever I move the main window that holds the static control, the bitmap disappears. If I move another window over it, it doesn't repaint properly. Any thoughts?
Posted on 2003-12-10 08:49:13 by rdaneel
If you have specified the SS_BITMAP style this should not be happening. Windows will automatically paint the bitmap for you. If you have not used the predefined style you will have to repaint the bitmap in your WM_PAINT handler of the subclassed static proc:

LOCAL	ps	:PAINTSTRUCT

LOCAL hdc :DWORD
LOCAL memdc :DWORD
LOCAL oldobj :DWORD

.ELSEIF uMsg == WM_PAINT
invoke BeginPaint,hWin,ADDR ps
mov hdc,eax
invoke CreateCompatibleDC,hdc
mov memdc,eax
invoke SelectObject,memdc,hBitmap
mov oldobj,eax
invoke GetClientRect,hWin,ADDR rect
invoke BitBlt,hdc,0,0,rect.right,rect.bottom,memdc,0,0,SRCCOPY
invoke SelectObject,memdc,oldobj
invoke DeleteDC,memdc
invoke EndPaint,hWin,ADDR ps


For larger bitmaps (>100x100) you will want to limit the drawing operation to the update area using the region passed in the rcPaint parameter of the PAINTSTRUCT structure.
Posted on 2003-12-10 08:57:28 by donkey