VC: document-based Printing

Source: Internet
Author: User

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 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.