ramsay
asked on
Disableing menuitems on the fly
Dear Experts,
How do you make a menu item into a variable?
And how do you disable the menu item while the program is running.
How do you make a menu item into a variable?
And how do you disable the menu item while the program is running.
ASKER
I have written a program that accepts a double click and is then supposed to disable a menu item.. but the code you gave me produces an assertion error..
any further suggestions..
here is the code below.
void CSCVisTestView::OnLButtonD blClk(UINT nFlags, CPoint point)
{
CMenu* pMenu = GetMenu();
pMenu->EnableMenuItem(ID_F ILE_NEW,MF _GRAYED)
CScrollView::OnLButtonDblC lk(nFlags, point);
}
any further suggestions..
here is the code below.
void CSCVisTestView::OnLButtonD
{
CMenu* pMenu = GetMenu();
pMenu->EnableMenuItem(ID_F
CScrollView::OnLButtonDblC
}
Just looking at you code GetMenu probably returns NULL as the menu is associated with the frame. Put ASSERT(pMenu) on the next line to find out.
Try CMenu* pMenu = GetParentFrame()->GetMenu( );
Try CMenu* pMenu = GetParentFrame()->GetMenu(
Ignor what I've said. Talking bollocks
ASKER
It worked tho.. ish only for the top items.. not the sub menus.
code so far is:
CMenu* pMenu = GetParentFrame()->GetMenu( );
pMenu->EnableMenuItem(ID_S MARTCARD_S TART,MF_GR AYED);
GetParentFrame()->DrawMenu Bar();
code so far is:
CMenu* pMenu = GetParentFrame()->GetMenu(
pMenu->EnableMenuItem(ID_S
GetParentFrame()->DrawMenu
ASKER
it didnt work for the ID_FILE_NEW tho.
CMenu* pMenu = GetMenu();
CMenu* pSubMenu = GetSubMenu(0);
pSubMenu->EnableMenuItem(I D_FILE_NEW ,MF_GRAYED )
CMenu* pSubMenu = GetSubMenu(0);
pSubMenu->EnableMenuItem(I
ASKER
I used this code.. but it didnt work.. No errors. but the new button wasnt greyed out..
(incase your wondering the ID_SMARTCARD_START) was a direct link of the menu bar and i was greyed out with the previous code)
CMenu* pMenu = GetParentFrame()->GetMenu( );
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->EnableMenuItem(I D_FILE_NEW ,MF_GRAYED );
GetParentFrame()->DrawMenu Bar();
(incase your wondering the ID_SMARTCARD_START) was a direct link of the menu bar and i was greyed out with the previous code)
CMenu* pMenu = GetParentFrame()->GetMenu(
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->EnableMenuItem(I
GetParentFrame()->DrawMenu
ASKER
I used this code.. but it didnt work.. No errors. but the new button wasnt greyed out..
(incase your wondering the ID_SMARTCARD_START) was a direct link of the menu bar and i was greyed out with the previous code)
CMenu* pMenu = GetParentFrame()->GetMenu( );
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->EnableMenuItem(I D_FILE_NEW ,MF_GRAYED );
GetParentFrame()->DrawMenu Bar();
(incase your wondering the ID_SMARTCARD_START) was a direct link of the menu bar and i was greyed out with the previous code)
CMenu* pMenu = GetParentFrame()->GetMenu(
CMenu* pSubMenu = pMenu->GetSubMenu(0);
pSubMenu->EnableMenuItem(I
GetParentFrame()->DrawMenu
ASKER
Auto grade is soon.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great Worked like a charm!
pMenu->EnableMenuItem( ... )