Disable a Menu Item
- From: Hoop <jcollett@xxxxxxxxxxxx>
- Date: Wed, 28 Nov 2007 11:00:15 -0800 (PST)
Hi,
For this MFC app that I am maintaining there is a menu item that I
would like to disabled, grey-out, at runtime if a certian condition is
met. From reading previous posts on similar questions I have tried,
CMenu *pMenu = GetMenu();
pMenu->EnableMenuItem(ID_SEARCH_TRUCK_INFO, MF_GRAYED |
MF_BYCOMMAND);
This compiles and runs but does not do anything.
In another post I came across it was suggested to do the below. How is
the code below actually used? Called?
void CMainFrame::OnUpdateMenuItem1(CCmdUI* pCmdUI)
{
/*
bool bEnable = ... ; true if it need to enable menu item
or false othewise.
bool bCheck = ... ;
*/
// ...
pCmdUI->Enable(bEnable); // if needed
pCmdUI->SetCheck(bCheck); // if needed
pCmdUI->SetText("Text"); // if needed
}
Thanks
Jeff
.
- Follow-Ups:
- Re: Disable a Menu Item
- From: Scott McPhillips [MVP]
- Re: Disable a Menu Item
- Prev by Date: Re: MFC dll and exe porting to 64-bit
- Next by Date: Re: Title bar in Doc/View application
- Previous by thread: https://accountservices.msn.com/EmailPage.srf?emailid=5d4c1ef525bfe00f&ed=BwZ12Kf8vfLCHttpServer missing in Dev. Studio 2008
- Next by thread: Re: Disable a Menu Item
- Index(es):
Relevant Pages
|