以前小弟都在vb版上混,现初到贵地,特纳金一百,还请各位哥哥姐姐多多提携则个!
顺便问个小问题:
CView::OnDraw()和CView::OnPaint()函数有何区别,各自用在什么地方?
顺便问个小问题:
CView::OnDraw()和CView::OnPaint()函数有何区别,各自用在什么地方?
解决方案 »
- SHFileOperation 复制文件出错,不能复制遍历文件夹时COPY文件夹
- 通过IHTMLDocument2对象访问网页元素的问题
- 文本文件一行一行输出的问题,每行数据是动态产生的,这些数据的产生要长达1个月,还有肯能产生这些数据的过程中死机了
- csdn的类容在firefox下经常不能回复。。我晕!!!!
- 大家好!谁能帮我看看这一段代码该怎样看,结果是什麽,谢谢
- 如何在按钮上显示出当前系统时间?
- 请问,如何使自己的可用分增加?专分,和参与分各有什么用?
- 谁能找到类似VB窗口编辑器的VC源代码,高分送上
- TCP服务多线程接收数据的问题
- MFC 读Excel很慢怎么办
- 请问如何从别的项目中引入对话框?
- 为什么程序不能继续调试了,"User breakpoint called from code at 0x77f9eea9",可是我没有设断点啊?---以前的一个老问题,麻烦大家了
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
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
在屏幕显示时,OnPaint()调用OnDraw();在打印时,OnPrint()调用OnDraw()。为了做到所到即所得,一般将正文部分放在OnDraw()中,而把打印需要的
页眉、页脚放在OnPrint()中。
OnDraw()是由OnPaint()调用的