This is sort of a cross post but I thought the more people who see it the better. I have a DC that is transparent, that is it is painted with a NULL_BRUSH. If I draw something onto the DC I get an image with transparency as I only draw those bits that are not backround. This works fine. My problem is that the image cannot be erased becuase patining with a NULL brush does not erase the image in the DC. I have tried just about everything but I can't seem to make it erase the previous image and still be transparent, I know there must be a simple answer to this but I'm stumped. I have included an example of what I mean as it's a bit hard to explain, press the button and the old image is still there even though I have painted over it with a null brush. So I guess in short my question is how the heck do I erase a DC ?
Posted on 2003-11-12 00:33:24 by donkey
add this to your WM_COMMAND message handler:

invoke GetDlgItem,[hWin],1001
[COLOR=red][b]push eax
mov ecx,eax
invoke GetWindowRect,ecx,addr rect
invoke ScreenToClient,hWin,addr rect.left
invoke ScreenToClient,hWin,addr rect.right [COLOR=teal];EDIT: forgot about this[/COLOR]
invoke InvalidateRect,hWin,addr rect,TRUE
pop eax[/b][/COLOR]
invoke InvalidateRect,eax,NULL,TRUE

and change your WM_PAINT handler to update only the needed rectangle:

invoke GetClientRect,,ADDR rect

and use

invoke BitBlt,,ps.rcPaint.left,,[ps.rcPaint.right],[ps.rcPaint.bottom],,ps.rcPaint.left,,SRCCOPY

instead of

invoke BitBlt,,0,0,[rect.right],[rect.bottom],,0,0,SRCCOPY
Posted on 2003-11-12 02:13:10 by Morris
Hi Morris,

Thanks, works perfectly. The code was just a demo, it was a custom toolbar that I needed to process so the update region was restricted already. The code for the toolbar ended up being:


invoke SendMessage, [hToolBar], TB_COMMANDTOINDEX, [wParam], 0
mov ecx,eax
invoke SendMessage, [hToolBar], TB_GETITEMRECT, ecx, ADDR rect
invoke MapWindowPoints,[hToolBar],[hWin],ADDR rect,2
invoke InvalidateRect,[hWin],ADDR rect,TRUE
JMP >>.exit

<edit : slight error corrected>
Posted on 2003-11-12 09:18:30 by donkey