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 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 overridable functions in the view at the appropriate times.
The following articles discuss how the framework supports printing and print preview: