class CPPDlg : public CDialogImpl<CTipDlg>
{
...
private:
CBitmapButton m_btnK;
}CPPDlg* pDlg = new CPPDlg;
...什么时候delete呢

解决方案 »

  1.   

    pDlg->DestroyWindow();
    什么时候需要就什么销毁
      

  2.   

    DestroyWindow只是销毁窗口呀,那我new出来的,在哪何时去delete呢
      

  3.   

    CDialogImpl::OnFinalMessage
    virtual void OnFinalMessage( HWND hWnd );ParametershWnd[in] A handle to the window being destroyed.ResCalled after receiving the last message (typically WM_NCDESTROY). Note that if you want to automatically delete your object upon the window destruction, you can call delete this; here.
    =======================================================
    FreeLaxy, your backup.
    =======================================================
      

  4.   

    MSDN上有的东西, 到论坛上发贴, 你有的是时间啊.
    =======================================================
    FreeLaxy, your backup.
    =======================================================
      

  5.   

    CDialogImpl::OnFinalMessage
    这个方法我试过,没有CBitmapButton m_btnK;是没事的。为什么我在这儿加了个CBitmapButton m_btnK,因为我试过会出现断言错误,
    cpp中的OnInitDialog
    m_btnClose.Create();
    m_btnClose.SetImageList( iml );
    m_btnClose.SetImages( 0, 1, 2, 3);
    m_btnClose.ShowWindow(SW_SHOW);
    ls的朋友,你试过像我这样的方法吗?
      

  6.   

    我写了N多ATL/WTL东西, 总是很幸运, 没碰上过.=======================================================
    FreeLaxy, your backup.
    =======================================================
      

  7.   

    如果你要在对话框上点一个按钮销毁对话框。你可以向父窗口发一个消息,比方UM_GOODBY,父窗口接到消息在消息响应函数就可以销毁窗口和删除对象了。
      

  8.   

    谢谢 gordon3000 此方法好用