动态创建菜单的事件处理 [英] Event handling of dynamically created menu

查看:98
本文介绍了动态创建菜单的事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个带有menu.in的程序,在运行时在其中添加了几个菜单项.单击这些菜单项时,我需要对其进行处理,因为我不知道菜单项的确切编号或ID,我该怎么办.
我看到此链接
但是我不能在MFC中实现它,有人可以提示我在MFC中实现它.
在此先谢谢您.

Hi I have a program which has a menu.in which at run time several menu items are added to it. I need to process these menu items when they are clicked,,Since I do not know the exact number or ID of the menu items,How can i do that.
I saw This link
But i am not able to implement it in mfc,Can anyone provide me a hint to do it in MFC.
Thanks in advance.

推荐答案

如果您知道命令ID的范围,则可以使用ON_COMMAND_RANGE.
例如,动态菜单项的命令ID为1000到2000,那么您可以通过ON_COMMAND_RANGE(1000,2000,OnMenuHandler)处理这些命令ID之间的所有命令.
If you know the range of command ID, then you can use ON_COMMAND_RANGE.
For example, command id of the dynamic menu items are from 1000 to 2000, then you can handle all commands between these command ids by ON_COMMAND_RANGE( 1000, 2000, OnMenuHandler).
afx_msg void OnMenuHandler(UINT nMenuID_i);


nMenuID_i可用于标识菜单项的ID.


nMenuID_i can be used to identify the id of menu item.


这篇关于动态创建菜单的事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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