Summary of Invalidate functions

xiaoxiao2021-03-06  93

InvalIdateRect just increasing the redraw area, take effect when WM_PAINT is next time

The parameter True in the InvaliDateRect function indicates that the system will overwrite the selected area before you draw, the default background color is white, and the background color can be changed by setting BRUSH.

After invalidate (): (MFC, in the way) onpaint () -> onpreparedc () -> OnDraw () So just refreshed the plot statement in the onpaint () and overdraw () functions. Other places have no effect.

Invalidate marks a unable area that needs to be redrawn does not mean redrawing immediately after calling the function. Similar to PostMessage (WM_Paint), it is really redrawn when you need to process the WM_PAINT message. Think of your invalidate, there are other statements that are being executed, and the program does not have the opportunity to deal with the WM_PAINT message, but when the function is executed, the message processing is taken.

Invalidate just puts a WM_PAINT message in the queue, not doing other, so only when the current function returns, go to the message loop, remove the WM_Paint, then execute the Paint, so regardless of INVALIDATE, it is the last.

InvalidateRect (hwnd, & review, true); sending a WM_Paint message to the HWND form, forced customer area re-draw, Rect is the area you specify to refresh, the customer area outside this area is not redrawn, which prevents one of the customer area Local changes, causing the entire customer area redrawing, resulting in flashing, if the last parameter is true, then send a WM_RASEBKGND message to the form, reloading the background, of course before the customer area is re-drawn. UpdateWindow only sends a WM_PAINT message to the form, judges that getUpdateRect (hwnd, null, true) before sending, if not, do not send WM_PAINT

If you want to refresh the invalid area immediately, you can call UpdateWindow after calling InvalIDate, if any part of the client area is invalid, the UpdateWindow will cause Windows to call the window process with the WM_PAINT message (if the entire customer area is valid, the window procedure is not called). This WM_PAINT message does not enter the message queue and is called directly by the Windows window process. After the window process completes the refresh, exit immediately, and Windows returns the statement that returns the statement after the UpdateWindow call. (Windows program design version 5 P98)

Updatedata () By the way, this function is not a refresh interface. Updatedata (); When the parameter is false, the data of the variable bound on the interface is directed to the control. When the parameter is TRUE, the import direction is the opposite.

转载请注明原文地址:https://www.9cbs.com/read-96099.html

New Post(0)