[Win32] Get pointer to a top menu item?

Started by
13 comments, last by Flimflam 13 years, 6 months ago
Quote:Original post by Erik Rufelt
Many menu functions have flags where you can specify MF_BYPOSITION to give it the index of the menu-item instead of the ID.


Hmm, I don't know if that applies here. I finally hacked it into working by doing this:
EnableMenuItem(GetMenu(hWnd),(unsigned int)(unsigned __int64)GetSubMenu(GetMenu(hWnd),3),MF_GRAYED);

I wonder if that is bad... lol
Advertisement
Just use 3 for the uIDEnableItem and use MF_BYPOSITION | MF_GRAYED for uEnable.
EnableMenuItem() supports MF_BYPOSITION. You should really consult the documentation rather than just hacking blindly and hoping things will work; your solution is highly unportable and liable to crash in certain circumstances.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

OOOH ok, now I understand. Thank you all very much!

By the way, I was using msdn, but it's kind of hard to find anything if you don't know what you're looking for. For example, this is what it showed me first: http://msdn.microsoft.com/en-us/library/aa984351(VS.71).aspx
Quote:Original post by xytor
OOOH ok, now I understand. Thank you all very much!

By the way, I was using msdn, but it's kind of hard to find anything if you don't know what you're looking for. For example, this is what it showed me first: http://msdn.microsoft.com/en-us/library/aa984351(VS.71).aspx


Keep in mind that says Windows Forms on that page. You're trying to do it in pure Win32.

Windows Forms is the managed framework designed around Win32 for writing .NET applications.

This topic is closed to new replies.

Advertisement