Click here to Skip to main content
12,998,892 members (67,805 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hy
I am trying to disable/enable an item menu in win32 project .
my code :

EnableMenuItem(GetMenu(hh), ID_FILE_SAVE,MF_ENABLED);


but it doesnt work . why ?
I dont understand . pleas help me
Posted 3-Oct-12 2:23am
Comments
Malli_S 3-Oct-12 8:38am
   
What error you're getting? What does GetLastError() returns ?
Richard MacCutchan 3-Oct-12 8:38am
   
Are you sure that ID_FILE_SAVE is on your main menu?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

You probably are using the wrong menu handle as the first parameter to the EnableMenuItem function.
Maybe you need to use the GetSubMenu function also.

Try this -
EnableMenuItem(GetSubMenu(GetMenu(hh), 0), ID_FILE_SAVE, MF_DISABLED | MF_GRAYED);

Here 0 is the position of the required sub-menu.
  Permalink  
Comments
Jochen Arndt 4-Oct-12 7:17am
   
Good catch: +5.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

See this link[^] and see the sample inside.

Another resource[^] that could help...

Good luck!
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

It should be like this, otherwise the system does not know how to interpret the second parameter.

EnableMenuItem(GetMenu(hh), ID_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
  Permalink  
Comments
Jochen Arndt 4-Oct-12 7:20am
   
You are basically right but this will not solve the problem because MF_BYCOMMAND is null.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100