Thread: Win32 - Can't enable menu in runtime

  1. #1
    Registered User
    Join Date
    Aug 2010

    Win32 - Can't enable menu in runtime

    Hi again,

    I changed a menu's propriety "Grayed" to True, and now the menu is unclickable. I wanted to enable it in runtime if a specific login is entered.

    I read some tutorials and articles, but I can't make the ModifyMenu() funtion work.

    BOOL WINAPI ModifyMenu(HMENU hMnu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpNewItem );
    I have the following code till now:

    HMENU hMenu;  //Handle to the menu
    hMenu = GetMenu(hWnd);  //getting handle to menu
    //IDR_ADMIN_CRIA_USER  <- Menu Item ID, the one I want to enable.
    This is done all after the window is created and configured. It's done in the WinProc() funtion.

    I don't know what to put in the last variable of the function so I've been just putting a NULL in it.

    To conclude, the proprieties I tried, were Greyed: True and Enabled: False. I can't reverse any of them with the code above.

    Can ayone give me some hints about how to work this function?

    Thanks in advance,


  2. #2
    Registered User
    Join Date
    Aug 2010
    Well I solved it using:

    EnableMenuItem(hMenu, IDR_ADMIN_CRIA_USER, MF_BYCOMMAND );
    Sorry for the posting and answeing. I have been at this since yesterday, and only when I posted I found this other funcion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  4. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM