Article ID: 161874
Article Last Modified on 12/10/2003
CWnd* pParentWnd = CWnd::GetSafeOwner(m_pParentWnd,&hWndTop);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.
/* Compile options needed: default
This code snippet displays a CPropertySheet in response to a right-mouse
click in the COleControl.
*/
void CTestCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
CPropertySheet sheet;
CMyPage page;
sheet.AddPage (&page);
// Prevent temporary objects from being destroyed.
AfxLockTempMaps ();
sheet.DoModal ();
// Allow temporary objects to be cleaned up.
AfxUnlockTempMaps ();
COleControl::OnRButtonDown(nFlags, point);
}
Additional query words: ocx
Keywords: kbbug kbfix kbnoupdate kbuidesign kblocalsvr kbvc500fix kbctrl KB161874