如何在 MFC 中启动对话框?
我对 VC++ 和 MFC 还很陌生,所以请耐心等待。我创建了一个新对话框,我想弄清楚当用户单击按钮时如何显示它。
我还没有为对话框创建类或头文件——我尝试使用类向导,但它非常糟糕并且不起作用。那,或者我做错了什么。如果你问我的话,其中任何一种可能性都一样。
那么,在创建源文件/头文件并启动/显示对话框时,我需要采取哪些步骤?这是一个模式对话框。
澄清:我知道我需要创建对话框类的实例,然后只需在其上调用 DoModal() ,但我不确定如何创建类文件(带和/或不带向导)。
I'm fairly new to VC++ and MFC, so bear with me. I have created a new dialog, and I want to figure out how to display it when the user clicks a button.
I have not create a class or header file for the dialog -- I tried using the class wizard, but it pretty much sucked and didn't work. That, or I was doing something wrong. Either one is equally as likely if you ask me.
So what steps do I need to take when creating the source/header files and getting the dialog to launch/display? It is a modal dialog.
CLARIFICATION: I understand that I need to create an instance of the dialog class, then just call DoModal() on it, but I'm not sure how to create the class file (with and/or without the wizard).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加|资源...
键入并单击新建。
CMyDialog
名称,基类的
CDialog
并单击“完成”。
了解更多:如何制作 MFC 对话框
Add | Resource...
type and click New.
CMyDialog
for the Classname,
CDialog
for the Base classand Click Finish.
Read more: How to Make MFC Dialog Boxes
在我看来,您可以单击按钮,只需创建对话框对象的新实例并激活它。您可能必须保留对对话框的引用,以便当按钮操作 fxn 返回时它不会被杀死,它不会被垃圾收集。
Seems to me you can make the button click just create a new instance of the dialog object and activate it. You'll probably have to keep a reference to the dialog so it doesn't get killed when the button action fxn returns it doesn't get garbage collected..