I'm trying to copy a bitmap from one on-screen DC to another.
The code below is in the WM_PAINT handler but it doesn't work
The code below is in the handler for a button and it works. The only difference between it and the code above is the destination DC is obtained differently
Any ideas why the first code doesn't work?
The code below is in the WM_PAINT handler but it doesn't work
invoke BeginPaint,hWnd,addr ps
invoke GetDC,hBoard
mov memDC,eax
invoke GetClientRect,hBoard,addr rect
mov eax,rect.bottom
sub eax,rect.top
mov ecx,rect.right
sub ecx,rect.left
invoke BitBlt,ps.hdc,0,0,ecx,eax,memDC,0,0,SRCCOPY
invoke ReleaseDC,hBoard,memDC
invoke EndPaint,hWnd,addr ps
The code below is in the handler for a button and it works. The only difference between it and the code above is the destination DC is obtained differently
invoke GetDC,hWnd
mov hDC,eax ;destination DC
invoke GetDC,hBoard
mov memDC,eax ;source DC(not a memory DC)
invoke GetClientRect,hBoard,addr rect
mov eax,rect.bottom
sub eax,rect.top
mov ecx,rect.right
sub ecx,rect.left
invoke BitBlt,hDC,0,0,ecx,eax,memDC,0,0,SRCCOPY
invoke ReleaseDC,hBoard,memDC
invoke ReleaseDC,hWnd,hDC
Any ideas why the first code doesn't work?
Hey MArtial =)
Long time no see :grin:
The second one is simple and easy to read. I have no problems with it. However I am having a little trouble reading the first one...
<SNIP>
Never mind... im an idiot sometimes LOL
</SNIP>
Long time no see :grin:
The second one is simple and easy to read. I have no problems with it. However I am having a little trouble reading the first one...
<SNIP>
Never mind... im an idiot sometimes LOL
</SNIP>
Both code snippets are in the same window procedure.
The first is in the WM_PAINT section
and the second is in the WM_COMMAND section.
The first is in the WM_PAINT section
and the second is in the WM_COMMAND section.
Hmm, after the button press do you invalidate the region that you need repainted before you invoke the paint routine?
You don't have to subtract the top and left because they're always 0.
Make sure that at least the window identified by hBoard or the other window has a class or private device context. Otherwise, it will be the same DC and you'll just copy the contents of hBoard's client area over itself.
Make sure that at least the window identified by hBoard or the other window has a class or private device context. Otherwise, it will be the same DC and you'll just copy the contents of hBoard's client area over itself.