MSDN中这样描述:
If you wish to create a modeless dialog, call Createin the constructor of your dialog class.
When you implement a modeless dialog box, always override the OnCancel member function and call DestroyWindow from within it. Don'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.

1.创建示例:
CXDialog *pDialog=new CXDialog();
pDialog->Create(CXDialog::IDD);
pDialog->ShowWindow(SW_SHOW);
 
2.关闭示例:
void CXDialog::PostNcDestroy()
{
    CDialog::PostNcDestroy();
    delete this;
}
void CXDialog::OnCancel()
{
    DestroyWindow();
}

 


本文链接地址: MFC学习笔记之7:如何创建关闭无模式对话框
https://blog.qingfengju.com/index.asp?id=112

上一篇: MFC学习笔记之6:不使用IDE,从命令行编译简单的MFC应用程序
下一篇: MFC学习笔记之8:创建UI线程

分类:Win32/C++ 查看次数:8209 发布时间:2009/7/8 23:43:41