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 ().