Dimming a pop-up menu

How could I dimmed a pop-up menu in run-time when I don't want any of the options in the pop-up menu be active?
maulingAsked:
Who is Participating?
 
migelConnect With a Mentor Commented:
Try this:
// inside window procedure which menu popup you want to disable
{
CMenu* pMenu = GetMenu();
if (pMenu)
{
// nIndex is the popup menu index (zero based in the Window menu bar
pMenu->EnableMenuItem(nIndex, MF_BYPOSITION|MF_GRAYED);
            DrawMenuBar();
}
}
0
 
axrajaCommented:
Assign the menu items' resource ids in a sequence. For example, if u r having a menu contains Add, Sub, Multiply and divide then the resource ids in the .res file should be like this.

Add 100
Sub 101
Multiply 102
Divide 103

paste the code below where u want to grey ur menu..

CMenu mnu;
mnu.LoadMenu (ID_MENU);
//ID_MENU is the resource id for the particular menu;

for (int i = 100; i <= 103; i++)
{
      mnu.EnableMenuItem (i, MF_GRAYED);
}
0
 
maulingAuthor Commented:
Sorry, I don't want to disable the menu item one by one, but just dimmed the menu so it couldn't select it.
0
 
captainkirkCommented:
sounds like you would just do as axraja suggested with the top level menu item...
0
All Courses

From novice to tech pro — start learning today.