Difference between updatewindow and invalidate
Msdn explanation
Updatewindow
The updatewindow function updates the client area of the specified window by sending a wm_paint message to the window if the window's update region is not empty. the function sends a wm_paint message directly to the window procedure of the specified window, bypassing the application queue. if the update region is empty, no message is sent.
Invalidaterect
The system sends a wm_paint message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.
A rough explanation of the Translation into Chinese is as follows:
Updatewindow: If there is no effect zone, the sending a wm_paint message will be sent to the window for processing immediately. If the message queue is not entered for waiting, the window will be refreshed immediately. Otherwise, nothing will be done.
Invalidaterect: Set the invalid partition. If the parameter is null, set the entire window to an invalid partition. When the applicationProgramWhen the message queue in the window of is empty, sending a wm_paint message (even if the update area is empty) will be accumulated in all invalidaterect update areas of sending a wm_paint message.
So the general usage is
1: Set invalid Zone
Invalidaterect
2: refresh now
Updatewindow ();
if you call updatewindow without calling invalidaterect, The updatewindow does not do anything.
If updatewindow is not called after invalidaterect is called, the system automatically sends a wm_paint message when the window message queue is empty.