Q:wm_paint the message is generated when the window is redrawn, when will the window be redrawn??
A:
Strictly speaking, the window is redrawn only when the WM_PAINT message is received
But there are many events that have caused the news,
Like what:
First created
Move
Change size
Showwindow/activate window/invalidate window ....
Why is the system not sending WM_PAINT messages when calling invalidate? Why do I have to wait until the app message queue is empty to send WM_PAINT messages? This is because the system treats the drawing operations in the window as a low-priority operation, so as to be pushed backwards as much as possible. However, this also helps to improve the efficiency of drawing: Two WM_PAINT messages between the InvalidateRect and Invaliatergn to invalidate the area will be added up, and then in a WM_PAINT message is updated once, It not only avoids updating the same area multiple times, but also optimizes the app's update operations.
such as this through InvalidateRect and invalidatergn to make the window area invalid, dependent on the system. The mechanism of sending WM_PAINT messages at the right time is actually an asynchronous way of working, i.e. there is a delay between the invalid window area and the sending WM_PAINT message;
Sometimes this delay is not what we want, and of course we can use SendMessage to send a WM_PAINT message after the invalid window area to force an immediate redraw, but instead of using Windows GDI provides us with more convenient and powerful functions: UpdateWindow and RedrawWindow. UpdateWindow checks the window's update region to send the WM_PAINT message when it is not empty; RedrawWindow gives us more control: whether to redraw non-client areas and backgrounds, whether to always send WM_PAINT messages regardless of the update Whether the region is empty or not.
Http://baike.baidu.com/view/1988590.htm
WM_PAINT messages are generated when the window is redrawn, and when the window is redrawn (asynchronously working, more efficient, more flexible)