Another Quick One

This is a discussion on Another Quick One within the Windows Programming forums, part of the Platform Specific Boards category; Hi again. I would like to know how to ungray menu items. I have looked through the threads on the ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    Another Quick One

    Hi again.

    I would like to know how to ungray menu items. I have looked through the threads on the boards on similar topics, and found a very popular method I'd like to use: EnableMenuItem. The problem is that I need to supply the menu handle, and um ... I don't exactly know what my menu handle is.

    I know this is a really dumb question, but I'm completely lost without the name of the handle. The code I'm using is in this thread : Bitmaps .

    Thanks, and sorry for my idioticness.

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    If your window has a menu, you can get the handle using the GetMenu function.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    I tried that, but on this line :

    EnableMenuItem( HMENU, ID_EXECUTE_DEFAULT, MF_GRAYED);

    It says : Syntax error before ',' token.

    It means the first one, after HMENU I think.
    Any suggestions ?

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Well, do you have something that is an HMENU? You just passed the HMENU modifier like a paramter.

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    not familiar win32 api ui

    WM_INITMENU

    Kuphryn

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    How do you mean ?

    EDIT: Oh, I get you. Yes, I have a HMENU menu.
    Last edited by Necrofear; 06-16-2006 at 11:58 AM.

  7. #7
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Would this not work for you?
    Code:
    EnableMenuItem(GetMenu(hwnd), ID_EXECUTE_DEFAULT, MF_GRAYED);
    Where hwnd is your window's handle. (And don't declare something as HMENU HMENU;... that causes confusion. At the very least: HMENU hMenu;.)

    Finally, that will gray (not ungray) the menuitem... to ungray you change MF_GRAYED to MF_ENABLED.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    Working

    Cool, it's working now !

    Thanks for all the replies people

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 08:48 PM
  2. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 11:33 AM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 08:24 PM

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