CPropertySheet::DoModal

This method displays a modal property sheet. The return value corresponds to the identifier of the control that closed the property sheet. After this method returns, the windows corresponding to the property sheet and all the pages are destroyed. The objects themselves still exist. Typically, you retrieve data from the CPropertyPage objects after DoModal returns IDOK.

virtual int DoModal( ); 

Return Value

IDOK or IDCANCEL if the function was successful; otherwise, it is zero or –1.

Remarks

To display a modeless property sheet, call CPropertySheet::Create instead.

The first time a property page is created from its corresponding dialog resource, it may cause a first-chance exception. This is a result of the property page changing the style of the dialog resource to the required style prior to creating the page. Because resources are generally read-only, this causes an exception. The exception is handled by the system, and a copy of the modified resource is made automatically by the system. The first-chance exception can thus be ignored.

Since this exception must be handled by the operating system, do not wrap calls to CPropertySheet::DoModal with a C++ try/catch block in which the catch handles all exceptions, for example, catch (...). This will handle the exception intended for the operating system, causing unpredictable behavior. Using C++ exception handling with specific exception types or using structured exception handling where the Access Violation exception is passed through to the operating system is safe, however.

Example

// Add two pages to a CPropertySheet object, then show the
// CPropertySheet object as a modal dialog. Both CStylePage
// and CColorPage are CPropertyPage-derived classes created
// by ClassWizard.

CPropertySheet dlgPropertySheet("Simple PropertySheet");

CStylePage     stylePage;
CColorPage     colorPage;
dlgPropertySheet.AddPage(&stylePage);
dlgPropertySheet.AddPage(&colorPage);

dlgPropertySheet.DoModal();

Requirements

**  Windows CE versions:** 1.0 and later  
  Header file: Declared in Afxdlgs.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also

CDialog::DoModal, CPropertySheet::Create, CPropertyPage