博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
再探MFC(四)创建对话框
阅读量:4120 次
发布时间:2019-05-25

本文共 1188 字,大约阅读时间需要 3 分钟。

以点击菜单弹出非模式对话框为例.

 

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.

 

你可能感兴趣的文章
反对任何应用程序以任何理由抢焦点
查看>>
C#中的try与finally
查看>>
数字家庭 (一) 开机
查看>>
探讨C++中一种管理内存的方法
查看>>
ATL工程由VC6升级到2003后不能编译为Release的解决方法
查看>>
思考一个模式识别与机器学习相关的问题
查看>>
VB调用DLL导出函数出现“Bad DLL call convention”的解决
查看>>
理解HTTP消息头 1
查看>>
理解HTTP消息头 2
查看>>
理解HTTP消息头 3
查看>>
理解HTTP消息头 4
查看>>
胡乱思考一些和COM有关的问题
查看>>
.Net中的TLS(线程局部存储)
查看>>
Flash的Socket与WebService功能
查看>>
一种基于.Net 2.0的另类AOP
查看>>
突然发现我的文章被转载了
查看>>
一种WEB表单验证的简单方法
查看>>
用.Net的动态代码生成功能实现AOP
查看>>
关于server to server通信时dialback握手的问题
查看>>
GLSL内置函数以及相关注意事项
查看>>