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.
JustinspopAsked:
Who is Participating?
 
joepaladinConnect With a Mentor Commented:
create a CMenu object

CMenu* pmenu = CMDIFrameWnd::GetMenu();

then call the objects GetMenuState
method to query each item by ID

pmenu->GetMenuState( UINT nID, UINT nFlags ) const;

use the corresponding function to
set the menu item

It's pretty self explanatory in the
documentation
0
 
JustinspopAuthor Commented:
Edited text of question.
0
 
JustinspopAuthor Commented:
This question is very urgent for me right now.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
nietodCommented:
Use the EnableMenuItem() function like

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

Let me know if you have any questions.
0
 
JustinspopAuthor Commented:
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
0
 
nietodCommented:
>> 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.
0
 
JustinspopAuthor Commented:
How do you identify it through the submenu handle?
0
 
nietodCommented:
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.
0
 
JustinspopAuthor Commented:
I think im going to have to traverse the menus.  thanks anyway
0
 
nietodCommented:
joepaladin, have your read the question history?
0
 
nietodCommented:
justinpop, what is happening to this question?
0
All Courses

From novice to tech pro — start learning today.