Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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 at 3-Oct-12 8:38am
   
What error you're getting? What does GetLastError() returns ?
Richard MacCutchan at 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 at 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 at 4-Oct-12 7:20am
   
You are basically right but this will not solve the problem because MF_BYCOMMAND is null.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

When I wrote EnableMenuItem(hMenu,ID_FILE_LOAD,MF_GRAYED);
it gives me right answer .but I wrote EnableMenuItem(hMenu,ID_FILE_LOAD,MF_ENABLED);
it dosnot work .
pleas hekp me
  Permalink  
Comments
Richard MacCutchan at 7-Oct-12 3:54am
   
You need to show more of your code, including the exact line that gives the error.
Joan Murt at 7-Oct-12 6:22am
   
Oh, the same than in my last post (comment) but add that the other members are not seeing the answers to your question directly, they have to navigate there... look at the right side of each post, you will see a reply button which will allow you to reply directly to the poster.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

last error is :
CXX0030: Error: expression cannot be evaluated
  Permalink  
Comments
Joan Murt at 7-Oct-12 6:21am
   
khosro, you shouldn't post your comments or extra informations as answers. Doing that you prevent other members to come to your post as it appears as massively answered. Apart of that it is not allowed to do that and you'll get downvoted. Your best bet is to add comments or even better improve your question and tell the other CPians that you've updated the question to add more information there... Good luck!

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,485
1 OriginalGriff 463
2 Manas Bhardwaj 383
3 Damith Weerasinghe 340
4 Tadit Dash 330
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 6,006
2 Peter Leow 4,500
3 Maciej Los 3,540
4 Abhinav S 3,513


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid