这是你的主窗口吧?对于所有的对象只要是new来初始化的,如果不用delete就会报那个错。

解决方案 »

  1.   

    此问题我也遇到过,:-(。
    在ExitInstance()加入 if (m_pMainWnd!=NULL)
    {
    delete m_pMainWnd;
    m_pMainWnd = NULL;
    }
      

  2.   

    我觉得对于窗口对象采用动态创建挺好的,这样就不须自己释放了,操作系统自己会释放:
    CWnd *m_pMainWnd = (CWnd*)RUNTIME_CLASS(CWnd)->CreateObject();
    m_pMainWnd->Create(........);
      

  3.   

    也可以重载void PostNcDestroy();void PostNcDestroy()
    {
       delete this;
    }
      

  4.   

    我的程序在运行中好像不会调用OnNcDestroy()
      

  5.   

    内存leak的情况很复杂呀
    把代码拿来大家瞅瞅,好给你说说呀,不然就空对空
      

  6.   


    OnNcDestroy()函数不是由你主动去调用的,请看一下它的帮助。This method is called by the framework when the nonclient area is being destroyed, and is the last method called when the Windows CE window is destroyed. The default implementation performs some cleanup, then calls the virtual method PostNcDestroy. Override PostNcDestroy if you want to perform your own cleanup, such as a delete this operation. If you override OnNcDestroy, you must call OnNcDestroy in your base class to ensure that any memory internally allocated for the window is freed.