[英]How Do I Launch a Dialog in MFC?
I'm fairly new to VC++ and MFC, so bear with me. 我刚接触VC ++和MFC,请多多包涵。 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). 澄清:我知道我需要创建一个对话框类的实例,然后在其上调用DoModal(),但是我不确定如何创建类文件(使用和/或不使用向导)。
CMyDialog
for the Class name, CDialog
for the Base class and Click Finish. CMyDialog
作为类名, CDialog
作为基类,然后单击Finish。 Read more: How to Make MFC Dialog Boxes 阅读更多: 如何制作MFC对话框
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..
您可能必须保留对对话框的引用,以便当按钮操作fxn返回时,它不会被杀死,而不会被杀死。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.