Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
- Return to MSVC
13.3.3..Modeless Property Sheets..................................................................
Like a regular dialog box, a property sheet can be created as a floating window. A
modeless property sheet does not display the OK, the Cancel or the Apply button. It
provides property pages that can be used to better manage available space.
A modeless property sheet is created using the same approach as a modal property sheet.
You can start by creating dialog boxes to be used as property pages. The dialog boxes
must have the same characteristics as those of a modal property sheet and you should
create a class for each one of them; a class based on CPropertyPage. After creating the
pages and their classes, you will need a property sheet class. You can directly use the
CPropertySheet class or derive your own class from it. To display the property sheet as
modeless, instead of calling the DoModal() method, use the CPropertySheet::Create()
member function. Its syntax is:
BOOL Create(CWnd* pParentWnd = NULL,
DWORD dwStyle = (DWORD)–1, DWORD dwExStyle = 0);
The pParentWnd argument is the object that owns the property sheet. This is usually the
class that calls or displays the property sheet. If you pass this argument with a NULL
value, then the desktop owns the property sheet.
The dwStyle argument allows you to specify the style used to display the property sheet.
You can use the same window styles we reviewed for the dialog box. You do not have to
provide a value for this argument. In that case, you can pass it as –1. This would provide
a title bar with the system Close button, a frame, and a border to the property sheet by
combining the WS_CAPTION, the WS_SYSMENU, the DS_MODALFRAME, the
WS_POPUP, the WS_VISIBLE, and the DS_CONTEXT_HELP styles
The dwExStyle argument allows you to specify the extended styles to use on the property
sheet. If you do not pass this argument or pass it as 0, the property sheet would have a
border based on the default WS_EX_DLGMODALFRAME style.