父窗口下有一个TAB控件,TAB控件上方的CpropertyPage窗口,我想通过CpropertyPage的按钮关闭包含TAB控件的窗口
CpropertyPage代码如下:
void Cpage1::OnButton1() 
{
// TODO: Add your control notification handler code here
UpdateData();
    xa=m_X1;xb=m_X2;
ya=m_Y1;yb=m_Y2;
::SendMessage(GetParent()->GetParent()->m_hWnd,WM_CLOSE,0,0);
}
主窗口中的代码:
void FillDrawInfo::OnClose() 
{
// TODO: Add your message handler code here and/or call default
delete   this; 
DestroyWindow(); 
CDialog::OnClose();
}
运行后弹出了一个错误对话框,显示:Debug Assertion Failed!

解决方案 »

  1.   

    delete this;不应该放在第一行吧
    自己都析构了Ram里面的后续代码就被移除了
      

  2.   

    你的FillDrawInfo是非模态对话框?
      

  3.   

    delete this 放在DestroyWindow中
      

  4.   

    void FillDrawInfo::OnClose() 
    {
    // TODO: Add your message handler code here and/or call default 
    DestroyWindow(); 
    //delete   this;
    CDialog::OnClose();
    }BOOL FillDrawInfo::DestroyWindow() 
    {
    // TODO: Add your specialized code here and/or call the base class
    delete this;
    return CDialog::DestroyWindow();
    }
    这样还是不行啊!
      

  5.   

    主窗口中的代码:
    void FillDrawInfo::OnClose() 
    {
    // TODO: Add your message handler code here and/or call default
    delete this; 
    DestroyWindow(); 
    CDialog::OnClose();
    }
    把这个函数去了试试
      

  6.   

    delete this在NcPostDestroy里才不会出错
      

  7.   

    BOOL FillDrawInfo::DestroyWindow() 
    {
    // TODO: Add your specialized code here and/or call the base classBOOL ret = CDialog::DestroyWindow();
    delete this;
    return ret;
    }
      

  8.   

    delete this在NcPostDestroy里才不会出错。CDialog的OnClose会DestroyWindow的。不需要你自己来。