The information in this article applies to:
SYMPTOMSCalling CPropertySheet::DoModal() from a method or message handler in a COleControl-derived class may cause an assert in WINOCC.CPP, line 325, when the property sheet is dismissed. CAUSE
The assert is in CWnd::EnableWindow() where it is checking if the m_hWnd
member of the CWnd object is valid.
This creates a temporary CWnd* called pParentWnd. RunModalLoop() is called
next and returns after the property sheet is dismissed. When MFC tries to
call EnableWindow() through the pParentWnd pointer, the m_hWnd is no longer
valid.This behavior occurs because during RunModalLoop(), COleControl::OnPaint() will be called. COleControl::OnPaint(), in turn, calls AfxUnlockTempMaps(). This function deletes temporary objects that were previously created. In this case, the "pParentWnd" pointer is being destroyed. RESOLUTIONYou can prevent temporary objects from being destroyed by calling AfxLockTempMaps() before CPropertySheet::DoModal(). You will need to call AfxUnlockTempMaps() after CPropertySheet::DoModal() to allow temporary objects to be cleaned up. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Visual C++ version 5.0. MORE INFORMATIONAfxLockTempMaps() and AfxUnlockTempMaps() are undocumented functions and may change in future versions of MFC. Sample Code
Additional query words: kbVC400bug ocx
Keywords : kbole kbMFC KbUIDesign kbVC kbVC500fix |
Last Reviewed: July 29, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |