PRB: Modal Property Sheet Not Modal in Propdlg Sample

Last reviewed: July 18, 1997
Article ID: Q132951
1.52 WINDOWS kbprg kbprb

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with: Microsoft Visual C++ for Windows, version 1.52

SYMPTOMS

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++.

CAUSE

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);

This problem does not occur in the 32-bit version implementation of modal property sheets, because the CPropertySheet::DoModal() member function, disables the application's top level window:

   // find parent HWND
   HWND hWndTopLevel;
   CWnd* pParentWnd = CWnd::FromHandle(
       AfxGetSafeOwner(m_pParentWnd, &hWndTopLevel));
   if (hWndTopLevel != NULL)
       ::EnableWindow(hWndTopLevel, FALSE);

However, in the 16-bit code, this functionality is missing:

    // find parent HWND
    CWnd* pParentWnd = CWnd::FromHandle(AfxGetSafeOwner(m_pParentWnd));

RESOLUTION

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.

MORE INFORMATION

Steps to Reproduce Behavior

  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.

  4. Observe that you are able to move to other windows.


Additional reference words: 2.52
KBCategory: kbprg kbprb
KBSubcategory: MfcMisc
Keywords : kb16bitonly MfcMisc kbprb kbprg
Technology : kbMfc
Version : 1.52
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.