以前小弟都在vb版上混,现初到贵地,特纳金一百,还请各位哥哥姐姐多多提携则个!
顺便问个小问题:
CView::OnDraw()和CView::OnPaint()函数有何区别,各自用在什么地方?

解决方案 »

  1.   

    CView::OnDraw 
    virtual void OnDraw( CDC* pDC ) = 0;ParameterspDCPoints to the device context to be used for rendering an image of the document.ResCalled 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. You can make graphic device interface (GDI) calls using the CDC object pointed to by the pDC parameter. You can select GDI resources, such as pens or fonts, into the device context before drawing and then deselect them afterwards. Often your drawing code can be device-independent; that is, it doesn’t require information about what type of device is displaying the image.To optimize drawing, call the RectVisible member function of the device context to find out whether a given rectangle will be drawn. If you need to distinguish between normal screen display and printing, call the IsPrinting member function of the device context. CView Overview |  Class Members |  Hierarchy ChartSee Also   CDC::IsPrinting, CDC::RectVisible, CView::OnPrint, CWnd::OnCreate, CWnd::OnDestroy, CWnd::PostNcDestroy
      

  2.   

    CView::OnPrint 
    virtual void OnPrint( CDC* pDC, CPrintInfo* pInfo );ParameterspDCPoints to the printer device context.pInfoPoints to a CPrintInfo structure that describes the current print job. ResCalled by the framework to print or preview a page of the document. For each page being printed, the framework calls this function immediately after calling the OnPrepareDC member function. The page being printed is specified by the m_nCurPage member of the CPrintInfo structure that pInfo points to. The default implementation calls the OnDraw member function and passes it the printer device context. Override this function for any of the following reasons: To allow printing of multipage documents. Render only the portion of the document that corresponds to the page currently being printed. If you’re using OnDraw to perform the rendering, you can adjust the viewport origin so that only the appropriate portion of the document is printed.
    To make the printed image look different from the screen image (that is, if your application is not WYSIWYG). Instead of passing the printer device context to OnDraw, use the device context to render an image using attributes not shown on the screen.
    If you need GDI resources for printing that you don’t use for screen display, select them into the device context before drawing and deselect them afterwards. These GDI resources should be allocated in OnBeginPrinting and released in OnEndPrinting.To implement headers or footers. You can still use OnDraw to do the rendering by restricting the area that it can print on. 
    Note that the m_rectDraw member of the pInfo parameter describes the printable area of the page in logical units.Do not call OnPrepareDC in your override of OnPrint; the framework calls OnPrepareDC automatically before calling OnPrint.ExampleThe following is a skeleton for an overridden OnPrint function:void CMyView::OnPrint( CDC *pDC, CPrintInfo *pInfo )
    {
       // Print headers and/or footers, if desired.
       // Find portion of document corresponding to pInfo->m_nCurPage.
       OnDraw( pDC );
    }CView Overview |  Class Members |  Hierarchy ChartSee Also   CView::OnBeginPrinting, CView::OnEndPrinting, CView::OnPrepareDC, CView::OnDraw
      

  3.   

    Do u understand?  u can get more via MSDN ....
      

  4.   

    lysde(无所谓)说对了,我就接接分吧。
      

  5.   

    OnPaint调用OnDraw,是CWnd 的成员函数,也是WM_PAINT的响应函数;OnDraw是CWiew的成员函数。
      

  6.   

    不会那么简单。
    在屏幕显示时,OnPaint()调用OnDraw();在打印时,OnPrint()调用OnDraw()。为了做到所到即所得,一般将正文部分放在OnDraw()中,而把打印需要的
    页眉、页脚放在OnPrint()中。
      

  7.   

    同意
    OnDraw()是由OnPaint()调用的