The MASM Forum

General => The Workshop => Topic started by: xiahan on October 31, 2012, 02:24:07 AM

Title: two invalidaterect why the message procedure just process one
Post by: xiahan on October 31, 2012, 02:24:07 AM

leftMove proc
mov eax,oneRect.left
mov paintRect.left,eax
add eax,10
mov paintRect.right,eax
mov eax,oneRect.top
mov paintRect.top,eax
mov eax,oneRect.bottom
mov paintRect.bottom,eax

add oneRect.left,10
add oneRect.right,10

add paintRect.left,40
add paintRect.right,40
mov bProcess,1
mov b2,1
invoke InvalidateRect,hWinMain,addr paintRect,FALSE
;invoke FillRect,hDC,addr paintRect,hBrush1
invoke SendMessage,hWinMain,WM_PAINT,NULL,NULL
sub paintRect.left,40
sub paintRect.right,40

mov bProcess,1
mov b2,0
invoke InvalidateRect,hWinMain,addr paintRect,FALSE
;invoke FillRect,hDC,addr paintRect,hBrush2
ret
leftMove endp


the whole asm file is attached,
theinvoke SendMessage,hWinMain,WM_PAINT,NULL,NULL
is added to make it work,if i quoted out it,it will only paint onece
Title: Re: two invalidaterect why the message procedure just process one
Post by: dedndave on October 31, 2012, 02:35:23 AM
first, invalidating the rectangle simply tells the OS what area needs to be updated - it does not cause the update
second, you should never send a WM_PAINT message directly
third, your last invalidate call is not followed by an update

to cause a WM_PAINT message to be sent...

InvalidateRect
UpdateWindow
Title: Re: two invalidaterect why the message procedure just process one
Post by: xiahan on October 31, 2012, 03:29:56 PM
dave,can you explain for not send WM_PAINT directly
Title: Re: two invalidaterect why the message procedure just process one
Post by: dedndave on October 31, 2012, 04:00:39 PM
well - that is how it is documented
the operating system sends this message to a window when it needs to be updated
you do, however, have some control over when a window needs to be updated
you can do this by use of functions like ValidateRgn, InvalidateRgn, ValidateRect, InvalidateRect, and a few others
the OS keeps track of the update region, and sends WM_PAINT, as required
if the update region is not empty, and you call UpdateWindow, a WM_PAINT message is sent

besides the documentation, there would be an issue of creating a valid PAINTSTRUCT structure to pass   :P
also - under some conditions, the background may need to be erased

there is a lot of info on MSDN about painting and drawing
i have read it several times - and still have to browse it to refresh my memory - lol
Title: Re: two invalidaterect why the message procedure just process one
Post by: xiahan on October 31, 2012, 10:25:18 PM
ok,dave,i will go to read microsoft's ambiguous doc;