Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Stingray Foundation Library User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

9.8 Using Print Preview with ATL

The CPrintPreviewFrameImpl class makes it easy to use print preview in ATL. It can be used to add print preview capabilities to ATL windows. It is a template class that takes the base window class as a template parameter. The CPrintPreviewFrameImpl class contains a print preview model, viewport, and controller. It takes care of creating and initializing the print preview model, viewport, and controller objects.

To use the CPrintPreviewFrameImpl class, just instantiate it with an ATL-based window class as the first template parameter. The CPrintPreviewFrameImpl class handles both the print and print preview commands. The command identifiers for both commands can optionally be passed in as template parameters. The default command identifiers are IDC_SFL_FILE_PRINT and IDC_SFL_FILE_PRINT_PREVIEW. The CPrintPreviewFrameImpl class defines the virtual method BeginPrintPreview(), which is called when a print preview command is received. The BeginPrintPreview() method takes care of creating and showing the print preview window. A corresponding EndPrintPreview() method closes the print preview window. The OnBeginPreview() and OnEndPreview methods give derived classes an opportunity to perform custom tasks before the print preview window is shown and after it is closed.

The CPrintPreviewFrameImpl class is actually an abstract base class. It defines the pure virtual method GetCurrentPrintable(), which must be implemented by derived classes. Rather than hardwiring into the framework knowledge of which object to print, as MFC does with Document/View, the GetCurrentPrintable() method allows the CPrintPreviewFrameImpl class to avoid making any assumptions about what to print.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.