退出对话框时要处理一些事情,比如delete[]用new分配的地址空间等,在哪里添加代码?我的对话框是new,然后再create出来的:
         DatabaseBackupDlg *db=new DatabaseBackupDlg;
db->Create(IDD_DIALOG_SQLBackup,NULL);
db->ShowWindow(SW_SHOW);

解决方案 »

  1.   

    非模态对话框的销毁:MSDN:
    When you implement a modeless dialog box, always override the OnCancel member function and call DestroyWindow from within itDon't call the base class CDialog::OnCancel, because it calls EndDialog, which will make the dialog box invisible but will not destroy it. You should also override PostNcDestroy for modeless dialog boxes in order to delete this, since modeless dialog boxes are usually allocated with new. Modal dialog boxes are usually constructed on the frame and do not need PostNcDestroy cleanup. 
      

  2.   

    对呀
    对于数据的东西在析构函数中处理即可
    如果涉及到控件建议放到DestroyWindow中
    按2楼说的
    如果要销毁自己就在PostNcDestro中delete this