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