Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Menu / Toolbar Disable - Enable

Status
Not open for further replies.

LizardKingSchwing

Programmer
Oct 12, 2001
96
0
0
NL
Hi

I have a form view which has a menu , toolbar and buttons. Now when I open up the app I want to be able to have the
toolbar,menu and buttons grayed out (disabled). Then when a password is entered they are enabled. -ungrayed. The buttons are no problem I have them working however i am having trouble disabling and re-enabling the menu items and toolbar. Any ideas , suggestions , etc. would be great..

cheers

LK--<
 
overide the UPDATE_COMMAND_UI handler of your menu item,
add code to your handler
void CYourViewClass::OnUpdateTest(CCmdUI* pCmdUI)
{
pCmdUI->Enable(aFlag);

}

set aFlag = false when you start up the program and set it to true after the user logs on.
 
I had come across this way of doing the task however the trouble is how do you overide the command. where is it in the class wizard exactly, also I where do I declare the flag so that I can set it when the user logs in.....

Thanks for the help

LK--<
 
Sorry found out where to set up the On_Command_UI stuff - now I want a variable which can be set in the view and is accessible to the main frame too - where do I put that

thanks

LK--<
 
Changing menus at runtime:
The following code shows how to gray out and disable, as well as enable, menu items during runtime execution. Other functions are available, but time does not permit me to discuss them. &quot;index&quot; will be the menu to edit. Example File = 0, Edit = 1

CMenu *menu, *submenu;
int index;

index = 0;
menu = GetMenu();
submenu = menu->GetSubMenu(index);
//disable *** choice in the menu
menu->EnableMenuItem(ID_***, MF_DISABLED | MF_GRAYED);
//enable *** choice in the menu
submenu->EnableMenuItem(ID_***, MF_ENABLED);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top