mfc 无模态(非模式)对话框的创建和关闭

简介: 版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/7369300 在MSDN...
版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/7369300
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 callDestroyWindow 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.

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();
}

相关文章
|
10月前
11 MFC - 模态对话框
11 MFC - 模态对话框
40 0
|
1月前
|
数据安全/隐私保护
【Qt 学习笔记】Qt窗口 | 对话框 | 模态与非模态对话框的创建
【Qt 学习笔记】Qt窗口 | 对话框 | 模态与非模态对话框的创建
185 4
|
4月前
win32编程 -- 模式对话框
win32编程 -- 模式对话框
28 1
|
4月前
win32编程 -- 无模式对话框
win32编程 -- 无模式对话框
27 0
|
4月前
MFC窗口创建机制
MFC窗口创建机制
25 0
win11取消右键菜单折叠恢复经典传统菜单模式方法解决
win11取消右键菜单折叠恢复经典传统菜单模式方法解决
478 0
|
程序员 Windows
【windows编程之对话框】对话框原理,对话框的创建
【windows编程之对话框】对话框原理,对话框的创建
MFC学习——如何在MFC对话框中添加一个显示网页的窗口(用vs2017以下版本,vs2017不支持)
MFC学习——如何在MFC对话框中添加一个显示网页的窗口(用vs2017以下版本,vs2017不支持)
348 0