- Invalidate adds a wm_paint message to the message queue, and its invalid zone is the entire customer zone.
- Updatewindow directly sends a wm_paint message. Its invalid zone range is the invalid zone of the wm_paint message in the Message Queue (up to one.
- The effect is obvious. After invalidate is called, the screen may not be updated immediately, because the wm_paint message is not necessarily in the queue header, and calling updatewindow will immediately execute the wm_paint message, bypassing the message queue.
- If you want to update the screen immediately after invalidate is called, add the updatewindow () statement.
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, sending a wm_paint message will be sent to the window for processing immediately. If the message queue is not entered for waiting, refresh the window 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 message queue of the window of the application is empty, sending a wm_paint message (even if the update area is empty) is accumulated in all invalidaterect update areas of sending a wm_paint message.
1: Set invalid Zone
Invalidaterect
2: refresh now
Updatewindow ();
If you call updatewindow without calling invalidaterect, then updatewindow does not do anything.??????
If you do not call updatewindow after invalidaterect is called, the system automatically sends a wm_paint message when the window message queue is empty.
When updatewindow () is called, a wm_paint message is sent, and the application automatically calls invalidate () After receiving the wm_paint message (),Therefore, invalidate () does not have to appear in the program code ()!
Updatewindow () is to send the wm_paint message immediately. It only takes effect for the declared invalid region,
Invalidate () is one of the methods in which the statement is invalid.
Invalidate () indicates that the customer region is invalid., Re-paint the next time wm_paint occurs.Wm_paint is maintained by the system. When the update area of cwnd is not empty and there are no other messages in the window message queue of the application, Windows sends a wm_paint message..
Invalidate contains a bool parameter to identify whether to fill the background color during repainting. Is the setbkcolor function used? Continue to study.
Updatewindow requires the system to re-paint the area immediately.
Someone asked a question online. He wrote the drawing function after invalidate but didn't execute it because invalidate was executed and then transferred to the paint command. So none of them are displayed.
I finally figured out that the image I painted was always flashing, because I used the invalidate () function in the painting, so he kept self-nesting, but the painted image kept flashing.
Invalidate puts the customer area in the redraw state, while updatewindow starts to redraw. However, it first checks whether the customer area is empty. If it is not empty, updatewindow does not execute. If it is empty, re-draw is performed.
Invalidat is finally called invalidatrectIn Windows API, only