Print process:
The OnPreparePrinting () function is used to print some information.
The OnBeginPrinting () function creates a print resource.
The OnPrepareDC () function specifies the information displayed on a page.
Call the OnPrint () function to print a page.
1. When using the Wizard to generate a single document and multi-document application, you can select whether the application supports print and print preview. (Part 1 of the wizard)
2. Convert the default MM_TEXT mode to the MM_LOENGLISH mode. The method is as follows: SetMapMode (MM_LOENGLISH );
3. Multi-page printing:
You can set the number of printed pages in the OnBeginPrinting () function during print or preview.
For example:
Void CTestView: OnBeginPrinting (CDC * pDC, CPrintInfo * pInfo)
{
// TODO: add extra initialization before printing
CTestDoc * pDoc = GetDocument ();
ASSERT_VALID (pDoc );
// Obtain the vertical resolution of the printed paper
Int height = pDC-> GetDeviceCaps (VERTRES );
// Obtain the number of 1 inch printable points on the printed paper
Int ypixnum = pDC-> GetDeviceCaps (LOGPIXELSY );
// Set the page number
PInfo-> SetMaxPage (3 * ypixnum * drawheight/height + 1 );
}
Solve the problem that the content on pages 1st and 2 is the same: Set the information on the top of the page.
As follows:
Void CTestView: OnPrepareDC (CDC * pDC, CPrintInfo * pInfo)
{
// TODO: Add your specialized code here and/or call the base class
If (pDC-> IsPrinting ())
{
PDC-> SetMapMode (MM_LOENGLISH );
// Obtain the vertical resolution of the printed paper
Int height = pDC-> GetDeviceCaps (VERTRES );
// Obtain the coordinates of the current page
Int y = height * (pInfo-> m_nCurPage-1 );
PDC-> SetViewportOrg (0,-y );
}
CView: OnPrepareDC (pDC, pInfo );
}