ID: Q132951
1.52 WINDOWS kbprg kbprb
The information in this article applies to:
A modal property sheet brougt up by running the PROPDLG sample allows you to switch to other windows (such as the view window) in the application, and choose menu items. This is not proper behavior for a modal property sheet.
This problem occurs only with the Propdlg sample included with Visual C++ version 1.52. It does not occur in the Propdlg sample included with the 32-bit versions of Visual C++.
This problem results from passing "this" to the constructor for the CModalShapePropSheet making the view the parent of the property sheet:
   void CShapesView::OnPropertySheetWithPreview()
   ...
       m_pModalShapePropSheet = new CModalShapePropSheet(this);
   // find parent HWND
   HWND hWndTopLevel;
   CWnd* pParentWnd = CWnd::FromHandle(
       AfxGetSafeOwner(m_pParentWnd, &hWndTopLevel));
   if (hWndTopLevel != NULL)
       ::EnableWindow(hWndTopLevel, FALSE);
    // find parent HWND
    CWnd* pParentWnd = CWnd::FromHandle(AfxGetSafeOwner(m_pParentWnd));
Pass NULL or a pointer to the application's main frame window as the parent to the property sheet to correct this behavior. This works because AfxGetSafeOwner() returns the top level window in either of these cases as the main frame window. Later, in the CPropertySheet::DoModal() function, a call to pParentWnd->EnableWindow(FALSE) causes the top level window to be disabled.
1. Run the PROPDLG sample included with Visual C++ version 1.52.
2. Select a shape.
3. On the Object menu, click Property Sheet with Preview. This brings up a
   modal property sheet.
Additional reference words: 2.52 KBCategory: kbprg kbprb KBSubcategory: MfcMisc
Keywords          : kb16bitonly kbnokeyword kbMFC kbVC 
Version           : 1.52
Platform          : WINDOWSLast Reviewed: July 20, 1997