在MFC中显示对话框 [英] Display a dialoge box in MFC

查看:117
本文介绍了在MFC中显示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在研究SDI View Architecture MFC应用程序,当用户单击帮助"时,我需要显示一个外部对话框.例子.到目前为止,我已经准备好对话框,并在示例按钮"上添加了事件处理程序,并添加了

Hi I''m working on an SDI View Architecture MFC application and I need to display an external dialog box when the user clicks Help -> Example. So far i have my dialog box ready and I added an event handler on the Example ''button'' and added

<pre lang="cs"><br />
void CtestSDIApp::OnHelpExample()<br />
{<br />
    rulesDlg testdlg;<br />
    testdlg.DoModal();<br />
}</pre><br />


我似乎看不出问题出在哪里,但是那行不通.它确实可以编译,但是仍然可以.

关于在MFC中显示对话框最简单的方法有什么建议吗?


I don''t seem to see where the problem is, but it doesn''t work. It does compile but yeah still.

Any suggestion on what''s the easiest way to display a dialog box in MFC?

thanks a lot!

推荐答案

第一步是将未调用处理程序的情况与对话框出现故障的情况区分开.

您可以在处理程序中放置一个断点,看看它是否命中,或在其中放置一个AfxMessageBox().
The first step is to distinguish the case where your handler isn''t being called from the case where the dialog box is malfunctioning.

You can put a breakpoint in the handler and see if it''s hit, or put an AfxMessageBox () in there.


好,它确实起作用了,我只需要将它与正确的.cpp文件,在这种情况下是我的文档,所以我发布的相同代码也起作用了.

谢谢您的帮助!
Ok it actually worked, I just had to associate it with the right .cpp file which in this case was my doc, so the same code i posted about worked.

Thanks for the help guys!


鉴于rulesDlg是正确定义的CDialog,这应该可以正常工作.如果您为rulesDlg发布代码,我们很可能会发现那里是否有问题.
That should work just fine given that rulesDlg is a properly defined CDialog. If you post you code for rulesDlg we can probably see if there''s anything wrong there.


这篇关于在MFC中显示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆