我做了一个对话框程序,创建了一个属性表单:CPropSheet,然后插入3个属性页,
还有一个退出按钮,当我退出的时候调用EndDialog(IDOK);而EndDialog调用
void CPropSheet::OnDestroy() 
{
CPropertySheet::OnDestroy();
}debug模式下老是出错 Debug Assertion Fail 
File:f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp 
line:906 
For information on how your program can cause an assertion failure,see thi Visual C++ documentation on asserts. 
(Press Retry to debug the application ) 
这样错误 
Release下就没有事,是否内存泄露了
请大家提供一下解决方法,谢谢

解决方案 »

  1.   

    void CWnd::AssertValid() const
    {
    if (m_hWnd == NULL)
    return;     // null (unattached) windows are valid // check for special wnd??? values
    ASSERT(HWND_TOP == NULL);       // same as desktop
    if (m_hWnd == HWND_BOTTOM)
    ASSERT(this == &CWnd::wndBottom);
    else if (m_hWnd == HWND_TOPMOST)
    ASSERT(this == &CWnd::wndTopMost);
    else if (m_hWnd == HWND_NOTOPMOST)
    ASSERT(this == &CWnd::wndNoTopMost);
    else
    {
    // should be a normal window
    ASSERT(::IsWindow(m_hWnd));                          //这里提示出错了 // should also be in the permanent or temporary handle map
    CHandleMap* pMap = afxMapHWND();
    ASSERT(pMap != NULL); CObject* p=NULL;
    if(pMap)
    {
    ASSERT( (p = pMap->LookupPermanent(m_hWnd)) != NULL ||
    (p = pMap->LookupTemporary(m_hWnd)) != NULL);
    }
    ASSERT((CWnd*)p == this);   // must be us // Note: if either of the above asserts fire and you are
    // writing a multithreaded application, it is likely that
    // you have passed a C++ object from one thread to another
    // and have used that object in a way that was not intended.
    // (only simple inline wrapper functions should be used)
    //
    // In general, CWnd objects should be passed by HWND from
    // one thread to another.  The receiving thread can wrap
    // the HWND with a CWnd object by using CWnd::FromHandle.
    //
    // It is dangerous to pass C++ objects from one thread to
    // another, unless the objects are designed to be used in
    // such a manner.
    }
    }
    请大家帮助一下,谢谢
      

  2.   

    估计是 3 个属性也析构的时候发现 m_hWnd 没清空又调用 Destroy 导致的吧,通常都与窗口句柄有关
      

  3.   

    不要调EndDialog(IDOK),用SendMessage(WM_CLOSE...