Microsoft KB Archive/132951

{|
 * width="100%"|

PRB: Modal Property Sheet Not Modal in Propdlg Sample

 * }

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 kbnokeyword kbMFC kbVC

Issue type :

Technology : kbAudDeveloper kbMFC