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

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

你可能感兴趣的:(c++)