virtual void OnPrint( CDC* pDC, CPrintInfo* pInfo );
Parameters
pDC
Points to the printer device context.
pInfo
Points to a CPrintInfo structure that describes the current print job.
Remarks
Called 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:
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.
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.
Example
The 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 );
}
For another example, see CRichEditView::PrintInsideRect.
CView Overview | Class Members | Hierarchy Chart
See Also CView::OnBeginPrinting, CView::OnEndPrinting, CView::OnPrepareDC, CView::OnDraw