cPrintDialog Class¶
The cPrintDialog class contains methods and properties to construct a printdlg handle required by the PrintReport method of the cDRReport class.
Selecting printer information to be used to print the report may be a very complex activity but can also be very simple.
Users and developers may use one or a combination of the following techniques:
- Print to the default printer using the Windows printer selection dialog but never open the dialog.
- Print to a specific printer bypassing the Windows printer selection dialog.
- Open the print selection dialog, let the user select the desired printer and change property settings.
- Set up properties for printing, open the dialog, and let the user select a different printer and/or change property page attributes.
Printer selection means retrieving a PrintDlg handle and passing this to the DataFlex Reports print routines. The PrintDlg handle points to a structure with information to be used. This structure contains information such as the number of copies and page ranges, but for extra information, it contains pointers to other structures. For controlling the printing, the most important member is a structure named DEVMODE. This structure contains information such as the use of duplex printing, use of color, scaling, paper size, and collating. These settings can be controlled by users from printer property pages.
The cPrintDialog class contains properties to control the printing. For example, when the program code sets the peDuplex property, the PrintDialog function sets a member of the DEVMODE structure. When the code sets the piCopies property, the amount of pages is passed via the PrintDlg structure and optionally via the DEVMODE structure, as copies information is present in two places.
Print to Default Printer¶
Using option 1 means temporarily changing the piFlags property of the print dialog structure so that the print dialog retrieves the information from the printer dialog without showing itself to the user. No properties that can change the aforementioned DEVMODE structure are used. piCopies and page range selection will be respected/used.
Programmatically printing to the default printer can be done by sending PrintToDefaultPrinter to the cDRReport object or setting the peOutputDestination
Prior to calling the PrintDialog function, an event OnPreShowPrintDialog is fired, and after this, an event OnPostShowPrintDialog is triggered.
The DEVMODE structure can be extended by printer driver manufacturers with their own information, and from a program, it is almost impossible to know what the manufacturer stores in the extension bytes. Passing or not passing this information to the printer may result in printing nicely or not printing at all.