标签:
以点击菜单弹出非模式对话框为例.
step1
资源视图添加对话框模板.重命名对话框资源ID.
step2
选中对话框,右键菜单点击添加类.
step3
在菜单项的消息处理函数中
CDialogAddContactdlg;
INT_PTR nResponse =dlg.DoModal();
if (nResponse ==IDOK)
{
}
else if (nResponse== IDCANCEL)
{
}
可以通过DoModel创建模式对话框,通过Create创建非模式对话框.Remarks解释了两种对话框类型.Dialog boxes are of two types: modal andmodeless. A modal dialog box must be closed by the user before the applicationcontinues. A modeless dialog box allows the user to display the dialog box andreturn to another task without canceling or removing the dialog box.
如何关闭对话框?Remarks介绍如下.
A modal dialog boxcloses automatically when the user presses the OK or Cancel buttons or whenyour code calls the EndDialog member function.
When you implement amodeless 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 willnot destroy it. You should also override PostNcDestroy for modeless dialogboxes in order to delete this, since modeless dialog boxes are usuallyallocated with new. Modal dialog boxes are usually constructed on the frame anddo not need PostNcDestroy cleanup.
https://msdn.microsoft.com/en-us/library/132s802t.aspx
标签:
原文地址:http://blog.csdn.net/soliddream66/article/details/44832819