delete this?这句话怎么感觉这么怪..

解决方案 »

  1.   

    delete this 改在PostNcDestroy( );之后试试
      

  2.   

    我单步调试 问题出在DestroyWindow();
      

  3.   

    你在CSetDlg::PostNcDestroy( )函数中加个断点试试。
    执行DestroyWindow()时,会调用PostNcDestroy()函数。
      

  4.   

    没有进去,直接在DestroyWindow()这里就出现问题了
      

  5.   

    DestroyWindow做了什么操作? 提示是什么错误?
      

  6.   

    这个函数没改的。
    我把
      delete m_dlg1;
      delete m_dlg2;
    去除,在child子对话框中加入解析函数
    ~ChildDlg()
    {
      delete this;
    }
    就不在出现错误了,这是什么原因
      

  7.   

    DestroyWindow没做任何修改,我把
    delete m_dlg1;
    delete m_dlg2;
    去除,在child子对话框中加入了解析函数
    ~ChildDlg()
    {
      delete this;
    }
    就不会出现销毁对话框报错问题了,这是什么原因?
      

  8.   

    调用DestoryWnd会销毁所有的床体, 包括子wnd的。你调用delete dlg, 那你的child里是不是已经调用过了自己的DestoryWnd, 你看看。 如果是, 那样destroy应该有问题。
      

  9.   

    child中一开始没有调用任何销毁的函数,我把销毁在对话框中进行。那样就一直出现错误,编译没问题。
    执行的时候一直错误是0x内存不能读。
      

  10.   

    这个很简单的调试, 你在child的destory里放个断点, 然后在delete m——dlg1这放个断点, 然后看看这个语句执行时是否调用dlg1的destory
      

  11.   

    If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated child or owned windows when it destroys the parent or owner window. The function first destroys child or owned windows, and then it destroys the parent or owner window.
      

  12.   

    child中我没有加入destory函数,
    而后面加入的
    ~ChildDlg()
    {
      delete this;
    }
    会被执行到。
      

  13.   

    调用DestroyWindow()时会自动先销毁其子对话框,所以,楼主不需要自己销毁子对话框。请去掉“
    delete m_dlg1;
    delete m_dlg2;

    试试。