How to tell if a document is being printed

In your code, you might need to determine if your draw routine is going to the screen or to a printer. For example, you might want to draw grid lines if you are drawing to the screen, and no grid lines if you are drawing to the printer.

To determine if you are printing to the printer, you need to check inside the draw routine for every drawable view where you expect printing to make a difference. The TPrintingFlagSnapshot class gives you access to the printing flag in the Grafport.

The following example shows how to check for printing:

      TPrintingFlagSnapshot areWePrinting(port); // port is Grafport passed to the draw call.
      
      // Then every place you need to know ...
      if (areWePrinting.IsPrintingPort()) {
          // Write the code to use when printing here
      }
      else {
          // Write the code when not printing here
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker