MFC菜单资源和对话框 [英] MFC Menu Resource and Dialog Box
本文介绍了MFC菜单资源和对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图弄清楚如何在VS2010中向菜单资源添加功能,但不确定如何编程,因此当用户单击新建"时,它将显示一个对话框.我知道是否使用以下代码可以生成一个消息框.
I am trying to figure out how to add functionality to my menu resource in VS2010 and I am not sure how to program it so when the user clicks ''New'' it will display a dialog box. I know if I use the following code I can generate a message box.
<pre lang="cs">void MFC_Tutorial_Window::OnFileNew()
{
MessageBox("Clicked File->New");
}
对话框和DoModal可以使用相同类型的东西吗?
谢谢!
Will the same type of thing work for a dialog box and DoModal?
Thanks!
推荐答案
单击菜单项时,您的程序将收到一条WM_COMMAND
消息,其中包含用于标识选择了哪个菜单项的参数.此时,您所做的可能是从显示MessageBox()
到您可以想象的任何事情.
When a menu item is clicked your program will receive aWM_COMMAND
message with parameters that identifies which menu item was selected. What you do at that point can be anything from showing aMessageBox()
, as you did here, to anything that your imagination can conjure up.
这篇关于MFC菜单资源和对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文