Click here to Skip to main content
11,411,263 members (65,535 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC VC++
I have a program which has a 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 18-Nov-12 7:06am
Edited 18-Nov-12 8:39am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 can be used to identify the id of menu item.
anonymous1310 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 149
1 Sascha Lefévre 110
2 OriginalGriff 103
3 Dave Kreskowiak 80
4 Maciej Los 78
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,983
2 Maciej Los 3,430
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web02 | 2.8.150414.5 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100