Udostępnij za pośrednictwem


Printing

Microsoft Windows implements device-independent display. In MFC, this means that the same drawing calls, in the OnDraw member function of your view class, are responsible for drawing on the display and on other devices, such as printers. For print preview, the target device is a simulated printer output to the display.

Your Role in Printing vs. the Framework's Role

Your view class has the following responsibilities:

  • Inform the framework how many pages are in the document.

  • When asked to print a specified page, draw that portion of the document.

  • Allocate and deallocate any fonts or other graphics device interface (GDI) resources needed for printing.

  • If necessary, send any escape codes needed to change the printer mode before printing a given page, for example, to change the printing orientation on a per-page basis.

The framework's responsibilities are as follows:

  • Display the Print dialog box.

  • Create a CDC object for the printer.

  • Call the StartDoc and EndDoc member functions of the CDC object.

  • Repeatedly call the StartPage member function of the CDC object, inform the view class which page should be printed, and call the EndPage member function of the CDC object.

  • Call overridable functions in the view at the appropriate times.

The following articles discuss how the framework supports printing and print preview:

What do you want to know more about?

See Also

Reference

Printing and Print Preview