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

版权声明:欢迎评论和转载,转载请注明来源。 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();
}

上一篇:如何在遍历list,vector,map时删除符合条件的元素


下一篇:ASP.NET下MVC1.0->2.0->3.0->4.0发展