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 ...

Get C++ Windows Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.