Dynamic submenus






2.53/5 (8 votes)
Mar 21, 2000

141261

3956
Some handy functions for adding and deleting submenus and menuitems in runtime
Here are some short handy functions for adding and deleting submenus and menu items in runtime.
To add a menu with some items in the file menu at a specified index, use:
MenuItemData data[] ={
ID_COMMAND_1, "First Item",
ID_COMMAND_2, "Second Item",
0, NULL
};
CMenu *pMenu = AddSubMenu(pMainFrm, file_menu_index, sub_menu_index, "Dynamic Menu", data);
To append an item to the menu later on, use:
AddSubMenuItem(pMenu, ID_COMMAND_3, "Third Item");
To remove a submenu again, use:
RemoveSubMenu(pMainFrm, file_menu_index, sub_menu_index);
To remove only one item, use:
RemoveSubMenuItem(pMenu, ID_COMMAND_1);
That's all. Enjoy!
License
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.