CPrintDialogEx Class

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

class CPrintDialogEx : public CCommonDialog

Members

Public Constructors

Name

Description

CPrintDialogEx::CPrintDialogEx

Constructs a CPrintDialogEx object.

Public Methods

Name

Description

CPrintDialogEx::CreatePrinterDC

Creates a printer device context without displaying the Print dialog box.

CPrintDialogEx::DoModal

Displays the dialog box and allows the user to make selections.

CPrintDialogEx::GetCopies

Retrieves the number of copies requested.

CPrintDialogEx::GetDefaults

Retrieves device defaults without displaying a dialog box.

CPrintDialogEx::GetDeviceName

Retrieves the name of the currently selected printer device.

CPrintDialogEx::GetDevMode

Retrieves the DEVMODE structure.

CPrintDialogEx::GetDriverName

Retrieves the name of the system-defined printer device driver.

CPrintDialogEx::GetPortName

Retrieves the name of the currently selected printer port.

CPrintDialogEx::GetPrinterDC

Retrieves a handle to the printer device context.

CPrintDialogEx::PrintAll

Determines whether to print all pages of the document.

CPrintDialogEx::PrintCollate

Determines whether collated copies are requested.

CPrintDialogEx::PrintCurrentPage

Determines whether to print the current page of the document.

CPrintDialogEx::PrintRange

Determines whether to print only a specified range of pages.

CPrintDialogEx::PrintSelection

Determines whether to print only the currently selected items.

Public Data Members

Name

Description

CPrintDialogEx::m_pdex

A structure used to customize a CPrintDialogEx object.

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.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CDialog

IObjectWithSite

IPrintDialogCallback

CCommonDialog

CPrintDialogEx

Requirements

Header: afxdlgs.h

See Also

Reference

CCommonDialog Class

Hierarchy Chart

CPrintInfo Structure