PrintDlg

  BOOL PrintDlg(lppd)    
  LPPRINTDLG lppd; /* pointer to structure with initialization data */

The PrintDlg function displays a Print dialog box or a Print Setup dialog box. The Print dialog box makes it possible for the user to specify the properties of a particular print job. The Print Setup dialog box makes it possible for the user to select additional job properties and configure the printer.

Parameters

lppd

Points to a PRINTDLG structure that contains information used to initialize the dialog box. When the PrintDlg function returns, this structure contains information about the user's selections. The PRINTDLG structure has the following form:

#include <commdlg.h>

typedef struct tagPD { /* pd */

DWORD lStructSize;

HWND hwndOwner;

HGLOBAL hDevMode;

HGLOBAL hDevNames;

HDC hDC;

DWORD Flags;

UINT nFromPage;

UINT nToPage;

UINT nMinPage;

UINT nMaxPage;

UINT nCopies;

HINSTANCE hInstance;

LPARAM lCustData;

UINT (CALLBACK* lpfnPrintHook)(HWND, UINT, WPARAM, LPARAM);

UINT (CALLBACK* lpfnSetupHook)(HWND, UINT, WPARAM, LPARAM);

LPCSTR lpPrintTemplateName;

LPCSTR lpSetupTemplateName;

HGLOBAL hPrintTemplate;

HGLOBAL hSetupTemplate;

} PRINTDLG;

Return Value

The return value is TRUE if the function successfully configures the printer. The return value is FALSE if an error occurs, if the user chooses the Cancel button, or if the user chooses the Close command on the System menu to close the dialog box. (The return value is also FALSE if the user chooses the Setup button to display the Print Setup dialog box, chooses the OK button in the Print Setup dialog box, and then chooses the Cancel button in the Print dialog box.)

Errors

Use the CommDlgExtendedError function to retrieve the error value, which may be one of the following:

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