Help and Support
 

powered byLive Search

How To Create a Modeless CPropertySheet with Standard Buttons

Article ID:146916
Last Review:November 21, 2006
Revision:3.2
This article was previously published under Q146916
Note Microsoft Visual C++ .NET (2002) supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.

SUMMARY

This article describes how to implement the standard OK, Cancel, and Apply buttons in a modeless CPropertySheet object.

MORE INFORMATION

For a modeless CPropertySheet, the Microsoft Foundation Classes (MFC) resize the sheet and hide the standard buttons in the CPropertySheet::OnInitDialog member function. To prevent MFC from doing this, perform the following steps:
Derive a class from CPropertySheet and override the OnInitDialog function.
Set "m_bModeless" to FALSE and remove the WF_CONTINUEMODAL style for "m_nFlags".
Call CPropertySheet::OnInitDialog.
Set "m_bModeless" back to TRUE and add the style WF_CONTINUEMODAL to "m_nFlags".
The following sample code illustrates this technique:
// CMySheet is derived from CpropertySheet.
// Compile options needed: default.
    
BOOL CMySheet::OnInitDialog()
{
   m_bModeless = FALSE;   
   m_nFlags |= WF_CONTINUEMODAL;

   BOOL bResult = CPropertySheet::OnInitDialog();

   m_bModeless = TRUE;
   m_nFlags &= ~WF_CONTINUEMODAL;
   return bResult;
}
				
In a modeless CPropertySheet object, the OK and Cancel buttons do not close the property sheet when they are clicked. They do send a WM_COMMAND message with IDOK or IDCANCEL to the sheet, and the OnOK or OnCancel functions are called for the page. To close the sheet, you can implement ON_COMMAND handlers for IDOK and IDCANCEL in the CPropertySheet and call the EndDialog function to close the sheet.

APPLIES TO
Microsoft Foundation Class Library 4.2, when used with:
  Microsoft Visual C++ 6.1
  Microsoft Visual C++ .NET 2002 Standard Edition
Microsoft Visual C++ .NET 2003 Standard Edition

Back to the top

Keywords: 
kbcode kbdlg kbhowto kbuidesign KB146916

Article Translations

 

Related Support Centers

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.