1、覆盖问题
2、销毁
重载OnCancel和PostNcDestroy函数
CModeLess.cpp
将Create第二个参数改成GetDesktopWindow()可解决
// 防止非模态对话框重复创建
CWnd* pWnd = FindWindow(0, "caption"); //caption对话框名
if(NULL == pWnd)
{
CDialog* dlg = new CDialog();
dlg->Create(IDD_DIALOG1, GetDesktopWindow());
dlg->ShowWindow(SW_SHOW);
}
else
{
pWnd->BringWindowToTop();
}
2、销毁
重载OnCancel和PostNcDestroy函数
CModeLess.h文件
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
afx_msg void OnCancel();
afx_msg void PostNcDestroy();
CModeLess.cpp
void CModeLess::OnCancel()
{
DestroyWindow();
}
void CModeLess::PostNcDestroy()
{
CDialogEx::PostNcDestroy();
delete this;
}