The PRINTDLG structure contains information that the PrintDlg function uses to initialize the Print dialog box. After the user closes the dialog box, the system uses this structure to return information about the user's selections.
typedef struct tagPD { // pd
DWORD lStructSize;
HWND hwndOwner;
HANDLE hDevMode;
HANDLE hDevNames;
HDC hDC;
DWORD Flags;
WORD nFromPage;
WORD nToPage;
WORD nMinPage;
WORD nMaxPage;
WORD nCopies;
HINSTANCE hInstance;
DWORD lCustData;
LPPRINTHOOKPROC lpfnPrintHook;
LPSETUPHOOKPROC lpfnSetupHook;
LPCTSTR lpPrintTemplateName;
LPCTSTR lpSetupTemplateName;
HANDLE hPrintTemplate;
HANDLE hSetupTemplate;
} PRINTDLG;
If hDevMode is NULL on input, PrintDlg allocates memory for the DEVMODE structure, initializes its members to indicate the user's input, and returns a handle that identifies it.
If the device driver for the specified printer does not support extended device modes, hDevMode is NULL when PrintDlg returns.
If the device name (specified by the dmDeviceName member of the DEVMODE structure) does not appear in the [devices] section of WIN.INI, PrintDlg returns an error.
For more information about the hDevMode and hDevNames members, see the Remarks section at the end of this topic.
The hDevNames member can be NULL, in which case, PrintDlg allocates memory for the DEVNAMES structure, initializes its members to indicate the user's input, and returns a handle that identifies it.
For more information about the hDevMode and hDevNames members, see the Remarks section at the end of this topic.
PD_ALLPAGES | |
The default flag that indicates that the All radio button is initially selected. This flag is used as a placeholder to indicate that the PD_PAGENUMS and PD_SELECTION flags are not specified. | |
PD_COLLATE | |
If this flag is set, the Collate check box is checked. If this flag is set when the PrintDlg function returns, the application must simulate collation of multiple copies. For more information, see the description of the PD_USEDEVMODECOPIESANDCOLLATE flag. |
|
PD_DISABLEPRINTTOFILE | |
Disables the Print to File check box. | |
PD_ENABLEPRINTHOOK | |
Enables the hook procedure specified in the lpfnPrintHook member. This enables the hook procedure for the Print dialog box. | |
PD_ENABLEPRINTTEMPLATE | |
Indicates that the hInstance and lpPrintTemplateName members specify a replacement for the default Print dialog box template. | |
PD_ENABLEPRINTTEMPLATEHANDLE | |
Indicates that the hPrintTemplate member identifies a data block that contains a preloaded dialog box template. This template replaces the default template for the Print dialog box. The system ignores the lpPrintTemplateName member if this flag is specified. | |
PD_ENABLESETUPHOOK | |
Enables the hook procedure specified in the lpfnSetupHook member. This enables the hook procedure for the Print Setup dialog box. | |
PD_ENABLESETUPTEMPLATE | |
Indicates that the hInstance and lpSetupTemplateName members specify a replacement for the default Print Setup dialog box template. | |
PD_ENABLESETUPTEMPLATEHANDLE | |
Indicates that the hSetupTemplate member identifies a data block that contains a preloaded dialog box template. This template replaces the default template for the Print Setup dialog box. The system ignores the lpSetupTemplateName member if this flag is specified. | |
PD_HIDEPRINTTOFILE | |
Hides the Print to File check box. | |
PD_NONETWORKBUTTON | |
Hides and disables the Network button. | |
PD_NOPAGENUMS | |
Disables the Pages radio button and the associated edit controls. | |
PD_NOSELECTION | |
Disables the Selection radio button. | |
PD_NOWARNING | |
Prevents the warning message from being displayed when there is no default printer. | |
PD_PAGENUMS | |
If this flag is set, the Pages radio button is selected. If this flag is set when the PrintDlg function returns, the nFromPage and nFromPage members indicate the starting and ending pages specified by the user. |
|
PD_PRINTSETUP | |
Causes the system to display the Print Setup dialog box rather than the Print dialog box. | |
PD_PRINTTOFILE | |
If this flag is set, the Print to File check box is selected. If this flag is set when the PrintDlg function returns, the offset indicated by the wOutputOffset member of the DEVNAMES structure contains the string "FILE:". When you call the StartDoc function to start the printing operation, specify this "FILE:" string in the lpszOutput member of the DOCINFO structure. Specifying this string causes the print subsystem to query the user for the name of the output file. |
|
PD_RETURNDC | |
Causes PrintDlg to return a device context matching the selections the user made in the dialog box. The device context is returned in hDC. | |
PD_RETURNDEFAULT | |
If this flag is set, the PrintDlg function does not display the dialog box. Instead, it sets the hDevNames and hDevMode members to handles to DEVMODE and DEVNAMES structures that are initialized for the system default printer. Both hDevNames and hDevMode must be NULL, or PrintDlg returns an error. If the system default printer is supported by an old printer driver (earlier than Windows version 3.0), only hDevNames is returned; hDevMode is NULL. |
|
PD_RETURNIC | |
Similar to the PD_RETURNDC flag, except this flag returns an information context rather than a device context. If neither PD_RETURNDC nor PD_RETURNIC is specified, hDC is undefined on output. | |
PD_SELECTION | |
If this flag is set, the Selection radio button is selected. If neither PD_PAGENUMS nor PD_SELECTION is set, the All radio button is selected. |
|
PD_SHOWHELP | |
Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING registered messages that the dialog box sends when the user clicks the Help button. | |
PD_USEDEVMODECOPIES | |
Same as PD_USEDEVMODECOPIESANDCOLLATE | |
PD_USEDEVMODECOPIESANDCOLLATE | |
This flag indicates whether your application supports multiple copies and collation. Set this flag on input to indicate that your application does not support multiple copies and collation. In this case, the nCopies member of the PRINTDLG structure always returns 1, and PD_COLLATE is never set in the Flags member. If this flag is not set, the application is responsible for printing and collating multiple copies. In this case, the nCopies member of the PRINTDLG structure indicates the number of copies the user wants to print, and the PD_COLLATE flag in the Flags member indicates whether the user wants collation. Regardless of whether this flag is set, an application can determine from nCopies and PD_COLLATE how many copies to render and whether to print them collated. If this flag is set and the printer driver does not support multiple copies, the Copies edit control is disabled. Similarly, if this flag is set and the printer driver does not support collation, the Collate checkbox is disabled. The dmCopies and dmCollate members of the DEVMODE structure contain the copies and collate information used by the printer driver. If this flag is set and the printer driver supports multiple copies, the dmCopies member indicates the number of copies requested by the user. If this flag is set and the printer driver supports collation, the dmCollate member of the DEVMODE structure indicates whether the user wants collation. If this flag is not set, the dmCopies member always returns 1, and the dmCollate member is always zero. |
When PrintDlg returns, nFromPage is the starting page specified by the user. If the Pages radio button is selected when the user clicks the Okay button, PrintDlg sets the PD_PAGENUMS flag and does not return until the user enters a starting page value that is within the minimum to maximum page range.
Windows 95: If the input value for either nFromPage or nToPage is outside the range specified by nMinPage and nMaxPage, PrintDlg returns an error.
Windows NT: If the input value for either nFromPage or nToPage is outside the minimum/maximum range, PrintDlg returns an error only if the PD_PAGENUMS flag is specified; otherwise, it displays the dialog box but changes the out-of-range value to the minimum or maximum value.
When PrintDlg returns, nToPage is the ending page specified by the user. If the Pages radio button is selected when the use clicks the Okay button, PrintDlg sets the PD_PAGENUMS flag and does not return until the user enters an ending page value that is within the minimum to maximum page range.
When you call the PrintDlg function, be sure that the wDeviceOffset member of the DEVNAMES structure is identical to the dmDeviceName member of the DEVMODE structure. If these members do not specify the same printer, PrintDlg initializes the dialog box using the printer specified by the wDeviceOffset member.
Typically, if both hDevMode and hDevNames are NULL, PrintDlg initializes the dialog box using the current default printer. However, if the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL, PrintDlg uses the hDevNames and hDevMode members to return information about the current default printer without displaying the dialog box.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winspool.h.
Unicode: Defined as Unicode and ANSI structures.
Common Dialog Box Library Overview, Common Dialog Box Structures, CreateDC, CreateIC, PrintDlg, DEVMODE, DEVNAMES, WM_INITDIALOG