Thread: EnableMenuItem has no affect

  1. #1
    Registered User
    Join Date
    Jun 2006

    EnableMenuItem has no affect

    I'm graying a few menu items from the resource editor and enabling them when some conditions are met. EnableMenuItem looks easy for this but it doesn't have any affect when I use it.

    I have a dialog with a menu on it and I used the hMenu after I did a LoadMenu(), aswell as the GetMenu() and it still has no affect with enabling the menu. The menu items I want to enable are on the menu bar if that means anything. I tried disabling an already enabled one but it has no affect either.

    EnableMenuItem(GetMenu(g_hWnd), IDM_MODE, MF_ENABLED);
    thanks in advance

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    You seem to be trying to enable/disable the WHOLE menu bar, that won't work. If you still can't get it to work, post the code of the menu creation.

  3. #3
    Registered User
    Join Date
    Jun 2006
    I made the menu in a resource editor, loaded it and then set it to the dialog window. The part of the menu I'm tyring to disable / renable are the equivalent of the File, Edit or View seen on many programs, not the entire menu bar.

    I can disable and renable the items inside those menus, but not the 'top level' items.

  4. #4
    Registered Abuser
    Join Date
    Jun 2006
    You need to specify that you are selecting the menu based on its identifier (IDM_MODE), which means you need to logically OR the MF_BYCOMMAND flag into the uEnable parameter.
    Also, make sure you are aware of the heirarchy of your menus. EnableMenuItem does exactly what it says, it enables an item in a menu, not the menu itself. If your menu is sitting in a menuBar, then the handle you need to pass as hMenu should be the menuBar handle:
    Quote Originally Posted by MSDN
    If the menu handle to the menu bar is specified, the top-level menu item (an item in the menu bar) is affected.
    Basically this means that hMenu specifies the menu that contains the item uIDEnableItem that you want to enable.
    Alternatively, you can also use SetMenuInfo if you are still unsure of the terminology.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hwang Woo-Suk is a douchebag - how does this affect stem cell research?
    By Govtcheez in forum A Brief History of
    Replies: 9
    Last Post: 01-12-2006, 08:09 AM
  2. will the header file affect the program?
    By Jasonymk in forum C++ Programming
    Replies: 5
    Last Post: 07-16-2003, 07:43 PM
  3. do pointers affect what they point to directly?
    By PHP in forum C++ Programming
    Replies: 6
    Last Post: 01-14-2003, 01:29 PM
  4. EnableMenuItem
    By Terrell in forum Windows Programming
    Replies: 1
    Last Post: 11-11-2001, 11:51 PM