News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

two invalidaterect why the message procedure just process one

Started by xiahan, October 31, 2012, 02:24:07 AM

Previous topic - Next topic

xiahan


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

dedndave

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

xiahan


dedndave

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

xiahan