Invalidate and updateallviews

Source: Internet
Author: User

Invalidate and updateallviews

The ondraw () function is executed whenever a window is repainted. It is similar to the message processing function onpaint. When onpaint () is added to the View class, onpaint () overwrites ondraw ().

 

Void invalidate (bool berase = true); this function is used to invalidate the entire window client. 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. Call it. The invalidate () function generates a wm_paint message and sends it to the Message Queue of the Windows application. MFC provides the message processing function onpaint of wm_paint for the window class. onpaint is responsible for repainting the window. There are some exceptions to the View class. The ondraw function is called in the onpaint function of the View class, and the actual re-painting is completed by ondraw. The default value of the berase parameter is true, that is, invalidate (true). The background in the repainting area is erased. Otherwise, the background remains unchanged.
Invalidate () is a member function of cwnd and has nothing to do with the DOC-VIEW. The invalidate (true) function can call the ondraw () function. If this-> invalidate () is used for only redrawing the current window, you can use invalidate (true) when you want to update the view when the drawing parameter is changed. There must be a premise that the drawing command is directly or indirectly completed in ondraw. Because we can create DC in many other functions for drawing

 

Updateallviews is a member function of cdocument, embodied in the spirit of DOC-VIEW. Is in the DOC/view structure, while updateallviews () is the relationship between documents and views, calling from it will make the updateview of all views related to the program and this document called. The updateview of each view determines whether to re-draw and how to draw it. Use getdocument ()-> updateallviews () (In view) or this-> updateallviews () (in DOC) to redraw all windows related to the current document ). Updateallviews
Does not go into the windows message queue, and the re-painting is directly generated.



Updatewindow (): updatewindow () is used to re-paint the window immediately. After the invalidate and other functions are called, the window will not be re-painted immediately. This is because the priority of the wm_paint message is very low. It must be processed after other messages in the message queue are sent. You can call the updatewindow function to send wm_paint directly to the target window, causing the window to be re-painted immediately.

 

Updateallviews () member functions of the cdocument class

If the document content changes for some reason, all views must be notified so that they can update the displayed data. The document class provides the updateallviews () function, which can complete the content mentioned above. The updateallviews () function declaration is as follows:

 

 Void updateallviews (cview * psender, lparam lhint = 0l, cobject * phint = NULL );

 

If the updateallviews () function is called in the member function of the derived class of the document, the first parameter is null, indicating that all documents related to the current document must be re-drawn; if you call updateallviews () through the pointer of the current document in the member functions of the view derived class, set the 1st parameters to the current view. The format is as follows:

 

 Getdoctument ()-> updateallviews (this ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.