Void Invalidate (Bool berase = true );
The Function The role is to make the entire window client area invalid. If the customer area of the window is invalid, it indicates that re-painting is required. For example, if a window that is covered by other windows is changed to a front-end window, the originally covered window is invalid and needs to be re-painted. In this case, Windows will apply Program Wm_paint messages are placed in the message queue. MFC provides wm_paint Message Processing for window classes Function Onpaint, onpaint is responsible for repainting the window. The View class has some exceptions. Function Ondraw Function The actual redrawing is completed by ondraw. If the berase parameter is true, the background in the repainting area is erased. Otherwise, the background remains unchanged.
: updatewindow () is used to re-paint the window immediately. Call invalidate and other function , the window will not be re-painted immediately. This is because the priority of the wm_paint message is very low, it must wait until other messages in the message queue are sent before being processed. Call updatewindow function to send wm_paint directly to the target window, this causes the window to be re-painted immediately
Invalidate (false) is directly painted without erasing the background
Invalidate (true) erased background
Invalidate () function usage
Invalidate (false) is directly painted without erasing the background
Invalidate (true) erased background
Invalidaterect only adds the re-painting area and takes effect the next time wm_paint.
The "true" parameter in the invalidaterect function indicates that the system overwrites the selected area with the background color before you draw the image. The default background color is white. You can change the background color by setting the brush.
After invalidate (): (MFC, By the way)
Onpaint ()-> onpreparedc ()-> ondraw ()
Therefore, we only need to refresh the drawing statement in the onpaint () and ondraw () functions. There is no impact elsewhere.
invalidate indicates an invalid area to be repainted. This does not mean that the function is re-painted immediately after being called. Similar to postmessage (wm_paint), the image is re-painted only when the wm_paint message is processed. If another statement is being executed after invalidate, the program has no chance to process the wm_paint message. However, after the function is executed, the message can be processed.
invalidate only puts a wm_paint message in the queue, and does not do anything else, therefore, only when the current function returns, it enters the message loop, and wm_paint is taken out to execute the painting. Therefore, wherever invalidate is put, it is the final one.
invalidaterect (hwnd, & re CT, true); send the wm_paint message to the hwnd form, force the customer region to be redrawn,
rect is the region you specified to refresh, the customer region outside this region is not re-painted. This prevents a local change to the customer region, leading to the re-painting of the entire customer region and flashing. If the final parameter is true, the wm_erasebkgnd message is also sent to the form so that the background is re-painted. Of course, before the customer area is re-painted.
updatewindow () only form send the wm_paint message. before sending the message, determine getupdaterect (hwnd, null, true) to see if there are any customer regions that can be drawn. If not, wm_paint is not sent.
If You Want To immediately refresh the invalid region, you can call inval Idaterect then calls updatewindow. If any part of the customer area is invalid, updatewindow will cause Windows to call the Window Process with the wm_paint message (if the entire customer area is valid, do not call Window Process ). the wm_paint message does not enter the Message Queue. The windows call window process. After the window is refreshed, exit immediately . Windows controls the statements returned to the program after updatewindow is called.
Updatedata () By the way, this function is not used to refresh the interface.
Updatedata (); when the parameter is true, the data of the variables bound to the control on the interface is imported to the control. If the parameter is false, the import direction is opposite.