I have a CMenu instance. I would like to dynamically traverse all menu and sub-menu items in the menu.
The API for getting a sub-menu is called CMenu::GetSubMenu. Its lone parameter is the sub-menu's position (zero based index) within the parent menu.
How do I get the positions of all sub-menus?
Call CMenu::GetMenuItemCount()
to determine the number of menu items. Iterate over the menu items, calling CMenu::GetSubMenu(nPos)
for each to determine whether that menu item has a submenu (i.e. the call does not return NULL
).