EnableMenuItem has no affect

This is a discussion on EnableMenuItem has no affect within the Windows Programming forums, part of the Platform Specific Boards category; I'm graying a few menu items from the resource editor and enabling them when some conditions are met. EnableMenuItem looks ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    36

    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.

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

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    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
    Posts
    36
    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
    Location
    Toronto
    Posts
    591
    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 Cprogramming.com
    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, 08: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21