Partager via


CPrintDialogEx Class

Encapsulates the services provided by the Windows 2000 Print property sheet.

class CPrintDialogEx : public CCommonDialog

Remarks

You can rely on the framework to handle many aspects of the printing process for your application. For more information about using the framework to handle printing tasks, see the article Printing.

If you want your application to handle printing without the framework's involvement, you can use the CPrintDialogEx class "as is" with the constructor provided, or you can derive your own dialog class from CPrintDialogEx and write a constructor to suit your needs. In either case, these dialog boxes will behave like standard MFC dialog boxes because they are derived from class CCommonDialog.

To use a CPrintDialogEx object, first create the object using the CPrintDialogEx constructor. Once the dialog box has been constructed, you can set or modify any values in the m_pdex structure to initialize the values of the dialog box's controls. The m_pdex structure is of type PRINTDLGEX. For more information on this structure, see the Windows SDK.

If you do not supply your own handles in m_pdex for the hDevMode and hDevNames members, be sure to call the Windows function GlobalFree for these handles when you are done with the dialog box.

After initializing the dialog box controls, call the DoModal member function to display the dialog box and allow the user to select print options. When DoModal returns, you can determine whether the user selected the OK, Apply, or Cancel button.

If the user pressed OK, you can use CPrintDialogEx's member functions to retrieve the information input by the user.

The CPrintDialogEx::GetDefaults member function is useful for retrieving the current printer defaults without displaying a dialog box. This method requires no user interaction.

You can use the Windows CommDlgExtendedError function to determine whether an error occurred during initialization of the dialog box and to learn more about the error. For more information on this function, see the Windows SDK.

For more information on using CPrintDialogEx, see Common Dialog Classes.

Requirements

Header: afxdlgs.h

See Also

Concepts

CPrintDialog Members

CCommonDialog Class

Hierarchy Chart

CPrintInfo Structure