2013年(34)
分类: C/C++
2013-03-21 16:31:01
afx_msg void OnPaint( );
Remarks
The framework calls this member function when Windows or an application makes a request to repaint a portion of an application’s window. The
message is sent when the or member function is called.
virtual void OnDraw( CDC* pDC ) = 0;
Remarks
Called by the framework to render an image of the document.
The framework calls this function to perform screen display, printing, and print preview, and it passes a different device context in each case. There is no default implementation.
You must override this function to display your view of the document.
If you need to distinguish between normal screen display and printing, call the member function of the device context.
区别已经很明显。OnPaint()是CWnd的成员函数,所有CWnd的子类都有一份OnPaint,而OnDraw()则是CView类中声明的纯虚函数。OnPaint()响应WM_PAINT消息,OnDraw不响应任何消息,只是一个虚函数。CWnd的子类分为四大类:FrameWindows, Dialog Boxes, Views, Controls,因此除了View及其子类使用OnDraw()外,其余三类都使用OnPaint()来重画。OnPaint()的工作是"Screen Display",而OnDraw()则可以做"Screen display, printing, print preview"等工作。