-
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.
-
If your window has a menu, you can get the handle using the GetMenu function.
-
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 ?
-
Well, do you have something that is an HMENU? You just passed the HMENU modifier like a paramter.
-
not familiar win32 api ui
WM_INITMENU
Kuphryn
-
How do you mean ?
EDIT: Oh, I get you. Yes, I have a HMENU menu.
-
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.
-
Working
Cool, it's working now !
Thanks for all the replies people :D