Thread: Enabling a menu

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    57

    Enabling a menu

    Hey guys, im trying to enable a menu item that is by default MFS_GRAYED, that is my shot:

    Code:
    MENUITEMINFO a;
    					a.fMask = MIIM_STATE;
    					GetMenuItemInfo(hMenu,ID_FILE_SAVERESULT,false,&a);
    					a.fState = MFS_ENABLED;
    					SetMenuItemInfo(hMenu,ID_FILE_SAVERESULT,false,&a);
    But it dont change the menu item status.
    What im doeing wrong?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    MSDN:

    Code:
    lpmii
        [in, out] Pointer to a MENUITEMINFO structure that specifies the information to retrieve and receives information about the menu item. Note that you must set MENUITEMINFO.cbSize to sizeof(MENUITEMINFO) before calling this function.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    57
    But theMSDN example code is exactly as mine, the sctruct defined as MENUITEMINFO and the function member as "&a".
    Oh... and if i set cbsize to (sizeof)a, the situation continues the same
    Last edited by Tropicalia; 10-04-2006 at 07:47 PM.

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Check return values of API's, getlasterror.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    57
    It said "a menu item wasnt found". So i realized that the menu was not hMenu, it was hSubMenu, but not the error that it return is "incorrect paramter").

    Sorry if the error messages are not exactly it, but they appear in portuguese here, and i try to translate it :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM