CPropertySheet::Create

 

Displays a modeless property sheet.

Syntax

      virtual BOOL Create(
   CWnd* pParentWnd = NULL,
   DWORD dwStyle = (DWORD)–1,
   DWORD dwExStyle = 0 
);

Parameters

  • pParentWnd
    Points to parent window. If NULL, parent is the desktop.

  • dwStyle
    Window styles for property sheet. For a complete list of available styles, see Window Styles.

  • dwExStyle
    Extended window styles for property sheet. For a complete list of available styles, see Extended Window Styles

Return Value

Nonzero if the property sheet is created successfully; otherwise 0.

Remarks

The call to Create can be inside the constructor, or you can call it after the constructor is invoked.

The default style, expressed by passing –1 as dwStyle, is actually WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME | DS_CONTEXTHELP | WS_VISIBLE. The default extended window style, expressed by passing 0 as dwExStyle, is actually WS_EX_DLGMODALFRAME.

The Create member function returns immediately after creating the property sheet. To destroy the property sheet, call CWnd::DestroyWindow.

Modeless property sheets displayed with a call to Create do not have OK, Cancel, Apply Now, and Help buttons as modal property sheets do. Desired buttons must be created by the user.

To display a modal property sheet, call DoModal instead.

Example

// This code fragment shows how to create a modeless property sheet 
// dialog in a command message handler (OnModelessPropertySheet()) 
// of a CView-derived class.
void CPSheetView::OnModelessPropertySheet()
{
   // Declare a CPropertySheet object.  m_pdlgPropertySheet is a data
   // member of type CPropertySheet in CView-derived class.
   m_pdlgPropertySheet = new CPropertySheet(_T("Simple PropertySheet"));
   ASSERT(m_pdlgPropertySheet);

   // Add three pages to the CPropertySheet object.  Both m_pstylePage, 
   // m_pcolorPage, and m_pshapePage are data members of type 
   // CPropertyPage-derived classes in CView-derived class.
   m_pstylePage = new CStylePage;
   m_pcolorPage = new CColorPage;
   m_pshapePage = new CShapePage;
   m_pdlgPropertySheet->AddPage(m_pstylePage);
   m_pdlgPropertySheet->AddPage(m_pcolorPage);
   m_pdlgPropertySheet->AddPage(m_pshapePage);

   // Create a modeless CPropertySheet dialog.
   m_pdlgPropertySheet->Create(); 
}
// The code fragment below shows how to destroy the C++ objects for
// propertysheet and propertypage in the destructor of CView-derived
// class.
// NOTE:  DestroyWindow() is called in CPropertySheet::OnClose() so
// you do not need to call it here.  Property pages are children
// of the CPropertySheet, they will be destroyed by their parents.
CPSheetView::~CPSheetView()
{
   delete m_pshapePage;
   delete m_pstylePage;
   delete m_pcolorPage;
   delete m_pdlgPropertySheet;
}

Requirements

Header: afxdlgs.h

See Also

CPropertySheet Class
Hierarchy Chart
CDialog::Create
CPropertySheet::DoModal