Print preview
The PrintPreviewDocument
class displays the pages of the document parent window. The OnKeyDown
method closes the document when the user presses the
Esc
key. The OnSize
method adjusts the physical size of the page so that the page always fits inside the window. The OnVerticalScroll
method shifts the pages when the user scrolls up or down, and OnPaint
calls OnPrint
of the parent document for each page.
PrintPreviewDocument.h:
namespace SmallWindows { class PrintPreviewDocument : Document { public: PrintPreviewDocument(StandardDocument* parentDocument, int page = 1, Size pageSize = USLetterPortrait); bool OnKeyDown(WORD key, bool shiftPressed, bool controlPressed);
The OnSize
function is overridden only to neutralize its functionality in Document
. In Document
, OnSize
modifies the scroll bars, but we do not want that to happen in this class:
void OnSize(Size clientSize) {/* Empty. */} void OnVerticalScroll...