bkkabi
asked on
How to disable the sub menuitem of the main menu in an SDI application?
How to disable the sub menuitem of the main menu in an SDI application? I tried with the following code its not working.
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
submenu->EnableMenuItem(ID _VIEW_ITEM 2, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
Can anyone help me with some explanation.
Thanks in Advance.
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
submenu->EnableMenuItem(ID
Can anyone help me with some explanation.
Thanks in Advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That could cause a few problems, but works better than manually doing it.
The best way to do it is to handle the On_Update messages sent for than menu item.
ON_UPDATE_COMMAND_UI(ID_VI EW_ITEM2, OnUpdateViewItem2)
void CMyClass::OnUpdateViewItem 2(CCmdUI* pCmdUI)
{
//You can replace false with a variable to keep track of whether you want the menu enabled or not
pCmdUI->Enable(false);
}
The best way to do it is to handle the On_Update messages sent for than menu item.
ON_UPDATE_COMMAND_UI(ID_VI
void CMyClass::OnUpdateViewItem
{
//You can replace false with a variable to keep track of whether you want the menu enabled or not
pCmdUI->Enable(false);
}
Hi,
U got ur prob solved? If u have any questions, u may ask them here.
VinExpert
U got ur prob solved? If u have any questions, u may ask them here.
VinExpert
from MSDN:
CMainFrame::CMainFrame()
{
// Set to FALSE so no ON_UPDATE_COMMAND_UI or
// ON_COMMAND handlers are needed, and
// CMenu::EnableMenuItem() will work as expected.
m_bAutoMenuEnable = FALSE;
}