The difference between onpaint () and ondraw:

Source: Internet
Author: User

The difference between onpaint () and ondraw:

1. invalidate () and invalidaterect () are actually calls to the onpaint () function,
The onpaint () function calls the ondraw () function,
The ondraw function also needs to support Printer output. The onpaint () function and the onprint () function both call ondraw (), so the same drawingCodeIt can be used either for screen output or for printer output.
In programming, you can load ondraw. If the onpaint () function is defined and there is content to be displayed in ondraw (), you need to call ondraw (), that is, ondraw (& DC ).

 

2. ondraw () is a virtual function called by onpaint (). It is defined as a pure virtual function in cview and must be overloaded. The device context is provided by onpaint.
Onpaint () is the response function of the Response Message wm_paint. In the default implementation, beginpaint () is called first, and endpaint is called finally.
Ondraw is recommended for programming.

 

3. cview encapsulates two functions, onpaint () and onprint (), which correspond to wm_paint and wm_print respectively. To provide a more standard and simple programming interface, MFC also provides the ondraw () function. Ondraw () will be called by onpaint () or onprint (), depending on the different DC (paint DC or printdc) passed in respectively, to complete screen painting or printing, you do not need to write code in two cases. Of course, if you only care about screen painting and do not care about Printing, you can directly reload onpaint () to complete painting without using ondraw ().

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.