Print Previewing

Print previewing is a totally cool feature. It is implemented in the MFC document/view architecture by creating two device contexts (DCs)—one for the printer and one for the screen. The printer DC is used to get the various metrics required for printing, such as the page size, printer resolution, the printable region, and so on. While the printing code is called to output the document, the screen DC is used for rendering the view to the screen. From the programmer's point of view, the print preview process is completely invisible. There is no distinction between a preview DC and any other DC in MFC—OK, there is a CDC::IsPrinting function to allow you to determine what kind of DC you have—and the printing code is executed as if the output were to the actual printer. Darn clever, don't you think?

The good news is that if you are using MFC document/view, you can provide print previewing with almost no effort. The bad news is that if you are using MFC but not document/view, or if you are not using MFC at all, providing a print preview isn't especially practical. You might want to consider this when you are designing your program.

One little-known fact is that you can make print previews interactive. Print previewing disables the document, so the user isn't able to interact with the document directly, but any menu or toolbar command that modifies the document can be used during the preview.

TIP
Make your print previews interactive when possible.

You should provide print previewing when you can. It helps your users and, as you'll see in the next section, it also helps you.



Developing User Interfaces for Microsoft Windows
Developing User Interfaces for Microsoft Windows
ISBN: 0735605866
EAN: 2147483647
Year: 2005
Pages: 334

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net