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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Gray Selections in Menu [file menu for example]

Status
Not open for further replies.

nbgoku

Programmer
May 25, 2004
108
US
how do i gray certain areas of a file menu, it seems EnableWindow() doest work with what i want, i want to gray certain selections in the Menu's when a certain selection is selected

i used Microsoft to build the menu

the Menu name is IDR_MENU1
inside the Menu is an option called Open (in the File menu), the ID of Open is ID_FILE_OPEN

anyone have any ideas or any tricks or shortcuts to graying Open? i dont want it grayed when the programs, i want it grayed when the user selects a different option from the File menu other then Open
 
Nb,

These are the functions that I wrote and use...

Code:
[blue]
void enableMenuItem(UINT ID)
{
     CMenu *Menu_Primary;
     Menu_Primary = GetMenu();
     Menu_Primary->EnableMenuItem(ID,MF_ENABLED);
}
void disableMenuItem(UINT ID)
{
     CMenu *Menu_Primary;
     Menu_Primary = GetMenu();
     Menu_Primary->EnableMenuItem(ID,MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
[/blue]
[green]//The UINT ID is the actual resource id of the button, in your case, ID_FILE_OPEN[/green]

[purple]disableMenuItem(ID_FILE_OPEN);[/purple]
[purple]enableMenuItem(ID_FILE_OPEN);[/purple]

[green]//Remember that these functions must be in the class that has the menu attached to it already, or else the GetMenu won't return anything[/green]

Hope that helps!
~Ron

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top