Question about InvalidateRect

Started by
0 comments, last by romer 21 years, 3 months ago
Tonight I was trying to find out how I could cause a WM_PAINT message be sent to my program so that my window would be repainted after I update one of the data structures, and I stumbled across the InvalidateRect function. It does the job fine right now, but I was just wondering will it always post a WM_PAINT message in the message queue for processing, or is that for only certain cases? Also, a bit of an aside, what are some practical uses for the UpdateWindow function other than using it right after window creation? Could it be used in place of InvalidateRect?
Advertisement
quote:Original post by MRom
will it always post a WM_PAINT message in the message queue for processing, or is that for only certain cases?

invalidaterect doesn''t directly cause WM_PAINT to be posted. it merely tells windows that a window or part of one needs to be repainted. if the application doesn''t do anything, WM_PAINT will be posted once the message queue is empty, and window will be redrawn. if you, for instance, call ValidateRect immediately after InvalidateRect, you won''t get WM_PAINT.
quote:
Also, a bit of an aside, what are some practical uses for the UpdateWindow function other than using it right after window creation? Could it be used in place of InvalidateRect?

you can use them together to ensure timely updates of your window. WM_PAINT will be posted and processed whenever there are no other messages pending in your queue, and that may take some time. if, however, you call InvalidateRect and immediately after that call UpdateWindow, your window will be updated regardless of how many messages are in your message queue.

or you can use RedrawWindow to achieve the same result.

This topic is closed to new replies.

Advertisement