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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

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

Let me know if you have any questions.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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
joepaladinCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
joepaladin, have your read the question history?
0
nietodCommented:
justinpop, what is happening to this question?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.