Link to home
Start Free TrialLog in
Avatar of Justinspop
Justinspop

asked on

Enabling/Disabling Menu Popups

In Visual C++, programmatically How Do I enable or disable a menu item that has a popup attached to it(items that appear with an arrow next to it) when enabling or disabling depends on the state of all submenus and menu items under it.
Avatar of Justinspop
Justinspop

ASKER

Edited text of question.
This question is very urgent for me right now.
Use the EnableMenuItem() function like

EnableMenuItem(hMenu,ItemPosition,MF_BYPOSITION | MF_DISABLED | MF_GRAYED);

Let me know if you have any questions.
Actually Im rejecting this answer, not because it doesnt answer it except it doesnot answer my need.  What happens when a view within a document is open maximized it throws off the offsets of the menus by 1, so in not all circumstances does Enablemenuitem work.  Is there a way to access all menu items within m_pSubmenu from the ccmdui parameter within ON_UPDATE_COMMAND_UI
>> Is there a way to access all menu items within
>> m_pSubmenu from the ccmdui parameter within >> ON_UPDATE_COMMAND_UI
I assume that is MFC-speak?

In non-MFC speak, you can iterate through the menu items in the menu using GetMenuItemInfo() until you find the menu item you want.  You can identify the munu item from the submenu handle it stored or from its menu ID.
How do you identify it through the submenu handle?
You have to save the sub-menu handle "somewhere" then when you iterate through the menu items look for one where the hSubMenu member of the MENUITEMINFO structure uequals this saved menu handle.

Alternately you can set the menu item's ID at the start, then look for that ID later.  

There might be better ways, but I don't know of any.
I think im going to have to traverse the menus.  thanks anyway
ASKER CERTIFIED SOLUTION
Avatar of joepaladin
joepaladin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
joepaladin, have your read the question history?
justinpop, what is happening to this question?