Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 18-Nov-12 7:39am
v6

1 solution

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).
C++
afx_msg void OnMenuHandler(UINT nMenuID_i);

nMenuID_i can be used to identify the id of menu item.
 
Share this answer
 
Comments
anonymous1310 18-Nov-12 13:10pm    
@Santhosh:Thanks for the answer i also thought about that but i have a nested sub menus ,how will i come to know which sub menu item has the id

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900