- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
模态对话框在应用继续进行之前必须关闭。非模态对话框允许用户执行另外的操作而不必取消或删除该对话框。
1 模块对话框
// 创建对话框
CMyDlg mydlg(this);
// 显示对话框
UINT_PTR dlgRet = cmdParamDlg.DoModal();
if(dlgRet != IDOK)
销毁模块对话框由系统自动回收,我们不需要手动释放。
2 非模态对话框
CMyDlg * mydlg = new CMyDlg ;
if ( NULL != mydlg )
{
mydlg ->Create(IDD_DLG_PLUGIN_CONSOLE, this);
mydlg ->ShowWindow(SW_SHOW);
}
很显然,需要我们手动释放这个对话框的资源。
根据msdn上的说法:
我们需要重载CMyDlg 这个对话框中的两个函数 OnCancel() 和 PostNcDestroy()
void CMyDlg ::OnCancel()
{
// TODO: Add your specialized code here and/or call the base class
this->DestroyWindow();
//父类的方法不需要再执行
//CDialog::OnCancel();
}
void CMyDlg :PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;
return; //直接return 不需要执行父类的PostNcDestroy()
} |
|