Creates a Printer dialog box that enables the user to specify the attributes of a printed page. These attributes include the paper size and source, the page orientation (portrait or landscape), and the width of the page margins.
CommDlg.ShowPrint
CommDlg.Copies [ = long ]
CommDlg.FromPage [ = long ]
CommDlg.ToPage [ = long ]
CommDlg.Min [ = long ]
CommDlg.Max [ = long ]
CommDlg.hDC [ = long ]
CommDlg.DevNames [ = string ]
The ShowPrint common dialog box allows the user to choose any printer and change the various settings. The controls of the dialog box are initialized using the associated CommDlg properties.
The Copies property specifies the initial number of copies to print.
The FromPage property specifies the page to start printing and the ToPage property the page to stop printing.
The Min and Max properties return or set the minimum and maximum allowed values for the print range.
The hDC property returns a device context for the printer selected in the Print dialog box when the cdpReturnDC flag is set or an information context when the cdpReturnIC flag is set.
The DevNames property returns the selected printer as a string with, comma delimited, Driver, Device, and Output Port. For example "WINSPOOL,HP Laserjet 4,LPT1:".
The Flags property values for ShowPrint indicate what services are requested in the dialog box.
Flags | Meaning |
---|---|
cdpAllPages $0 | The default flag that indicates that the All radio button is initially selected. |
cdpSelection $1 | The Selection radio button is selected. |
cdpPageNums $2 | The Pages radio button is selected. |
cdpNoSelection $4 | Disables the Selection radio button. |
cdpNoPageNums $8 | Disables the Pages radio button and the associated edit controls. |
cdpCollate $10 | The Collate check box is checked. |
cdpPrintToFile $20 | The Print to File check box is selected. |
cdpPrintSetup $40 | Display the Print Setup dialog box rather than the Print dialog box. |
cdpNoWarning $80 | Prevents the system from displaying a warning message when there is no default printer. |
cdpReturnDC $100 | Returns a device context matching the selections the user made in the dialog box. The device context is returned in hDC. |
cdpReturnIC $200 | Returns an information context matching the selections the user made in the dialog box. The device context is returned in hDC. |
cdpReturnDefault $400 | Returns the standard printer in DevNames without showing the dialog box. |
cdpShowHelp $800 | Displays the Help button |
cdpUseDevmodeCopies $40000 | Indicates whether your application supports multiple copies and collation. |
cdpDisablePrintToFile $80000 | Disables the Print to File check box. |
cdpHidePrintToFile $100000 | Hides the Print to File check box. |
cdpNoNetworkButton $2000000 | Hides and disables the Network button. |
This dialog box does not send data to the printer but lets the user specify how they want data printed. The following properties contain information about the user's selection: Copies, FromPage, and ToPage.
The printer device settings selected using the dialog box are made active when you make that printer the default printer for the application. This is accomplished by setting the Printer object to the CommDlg object.
OpenW 1
Ocx CommDlg cd
cd.Flags = 0
cd.ShowPrint' change printer settings
' the user wants:
Trace cd.Copies
Trace cd.FromPage
Trace cd.ToPage
Try
Set Printer = cd ' initialize the Printer object
Trace Printer.hDC
Trace Printer.Width
Trace Printer.DeviceName
Trace Printer.Orientation
Trace Printer.dmPaperSize
Catch
// Printer not set
EndCatch
CloseW 1
Debug.Show
The device mode settings for the printer are stored in the DEVMODE structure, which is a shared object between the ShowPrint and ShowPageSetup dialog box. The Printer object needs to be initialized with the DEVMODE structure before it can be changed using Printer properties. By default, the Printer object is initialized with the device mode settings from the Windows standard printer. When you change the DEVMODE structure through the use of the ShowPrint (or ShowPageSetup) dialog box, the Printer object needs to be re-initialized. This is accomplished by assigning the CommDlg object to the Printer object using Set.
In some builds of GB32, the 'Pages..to..from' section is disabled regardless of whether flag cdpPageNums is set or not; if you require this function, use Dlg Print instead.
CommDlg, ShowPageSetup, Dlg Print, dm-Properties
{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}