PrintDlg (function)
Other versions of this page are also available for the following:
8/28/2008
This function displays a Print or Print Setup dialog box. The Print dialog box enables the user to specify the properties of a particular print job.
For Windows CE 2.10 and later, this function has been replaced by PageSetupDlg (function).
Syntax
BOOL PrintDlg(
LPPRINTDLG lppd
);
Parameters
- lppd
Long pointer to a PRINTDLG (structure) that contains information used to initialize the dialog box. When PrintDlg returns, this structure contains information about the user's selections.
Return Value
If the user clicks the OK button, the return value is nonzero. The members of the PRINTDLG structure pointed to by the lppd parameter indicate the user's selections.
If the user canceled or closed the Print or Printer Setup dialog box or an error occurred, the return value is zero. To get extended error information, use the CommDlgExtendedError function. If the user canceled or closed the dialog box, CommDlgExtendedError returns zero; otherwise, it returns one of the following values:
CDERR_FINDRESFAILURE |
PDERR_CREATEICFAILURE |
CDERR_INITIALIZATION |
PDERR_DEFAULTDIFFERENT |
CDERR_LOADRESFAILURE |
PDERR_DNDMMISMATCH |
CDERR_LOADSTRFAILURE |
PDERR_GETDEVMODEFAIL |
CDERR_LOCKRESFAILURE |
PDERR_INITFAILURE |
CDERR_MEMALLOCFAILURE |
PDERR_LOADDRVFAILURE |
CDERR_MEMLOCKFAILURE |
PDERR_NODEFAULTPRN |
CDERR_NOHINSTANCE |
PDERR_NODEVICES |
CDERR_NOHOOK |
PDERR_PARSEFAILURE |
CDERR_NOTEMPLATE |
PDERR_PRINTERNOTFOUND |
CDERR_STRUCTSIZE |
PDERR_RETDEFFAILURE |
Remarks
If the hook procedure (pointed to by the lpfnPrintHook member of the PRINTDLG structure) processes the WM_CTLCOLORDLG message, the hook procedure must return a handle for the brush that should be used to paint the control background.
Calling PrintDlg with dwFlags equal to PD_RETURNDEFAULTDC causes the function to use the last-saved settings or the default settings. This can cause PrintDlg to fail if the settings are not valid. You should use the manual PrintDlg — that is, without the PD_RETURNDEFAULTDC — to choose a valid printer, port, or other destination to ensure that you can print to it.
When you are done with the device context (DC) returned by PrintDlg, call the DeleteDC function to delete it.
Requirements
Header | commdlg.h |
Library | commdlg.lib |
Windows Embedded CE | Windows CE 2.0 and later |
See Also
Reference
CommDlgExtendedError
CreateDC
DeleteDC
PrintHookProc
StartDoc
PageSetupDlg (function)
WM_CTLCOLORDLG
PAGESETUPDLG (structure)
PRINTDLG (structure)