PrintDlgEx function

Displays a Print property sheet that enables the user to specify the properties of a particular print job. A Print property sheet has a General page that contains controls similar to the Print dialog box. The property sheet can also have additional application-specific and driver-specific property pages as well as the General page.

Syntax

HRESULT WINAPI PrintDlgEx(
  _Inout_ LPPRINTDLGEX lppd
);

Parameters

  • lppd [in, out]
    Type: LPPRINTDLGEX

    A pointer to a PRINTDLGEX structure that contains information used to initialize the property sheet. When PrintDlgEx returns, this structure contains information about the user's selections.

    This structure must be declared dynamically using a memory allocation function.

Return value

Type: HRESULT

If the function succeeds, the return value is S_OK and the dwResultAction member of the PRINTDLGEX structure contains one of the following values.

Return code/value Description
PD_RESULT_APPLY 2

The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked.

PD_RESULT_CANCEL 0

The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged.

PD_RESULT_PRINT 1

The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user.

 

If the function fails, the return value may be one of the following COM error codes. For more information, see Error Handling.

Return code Description
E_OUTOFMEMORY

Insufficient memory.

E_INVALIDARG

One or more arguments are invalid.

E_POINTER

Invalid pointer.

E_HANDLE

Invalid handle.

E_FAIL

Unspecified error.

 

Remarks

The values of hDevMode and hDevNames in PRINTDLGEX may change when they are passed into PrintDlgEx. This is because these members are filled on both input and output. Be sure to free the memory allocated for these members

If PD_RETURNDC is set but PD_USEDEVMODECOPIESANDCOLLATE flag is not set, the PrintDlg and PrintDlgEx functions return incorrect number of copies. To get the correct number of copies, ensure that the calling application always uses PD_USEDEVMODECOPIESANDCOLLATE with PD_RETURNDC.

For more information, see Print Property Sheet.

Examples

For an example, see Using the Print Property Sheet.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Commdlg.h (include Windows.h)

Library

Comdlg32.lib

DLL

Comdlg32.dll

Unicode and ANSI names

PrintDlgExW (Unicode) and PrintDlgExA (ANSI)

See also

Reference

PrintDlg

PRINTDLGEX

Conceptual

Common Dialog Box Library

Other Resources

CreatePropertySheetPage