[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Simple CMenu question

Posted on 1998-05-28
5
Medium Priority
?
356 Views
Last Modified: 2013-11-20
Can anyone tell me why this code is not shading out the menu choice I want it to?

CMenu* TmpMenuPtr;
      
      if(_cAliasButton)
              _cAliasButton->EnableWindow(FALSE);
      TmpMenuPtr = GetMenu();
      if(TmpMenuPtr)
              TmpMenuPtr->EnableMenuItem(ID_ALIAS, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
_cAliasButton is a button in the window, and I'm trying to gray the menu choice when I gray the button.
Thanks.
0
Comment
Question by:Beatachon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 200 total points
ID: 1315680
And this is in an MFC application?  If so, the reason the menu isn't going gray is that MFC uses OnUpdateCommandUI() notifications to decide the state of UI elements like menus. You should move your code to an OnUpdateCommandUI() handler for your menu item, and make your call against the pCmdUI object your handler is passed instead of calling GetMenu().

.B ekiM
0
 

Author Comment

by:Beatachon
ID: 1315681
Do I have to derive my own class from CControlBar, or can I catch this message in my window's message map?
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1315682
How does this involve CControlBar?

.B ekiM
0
 

Author Comment

by:Beatachon
ID: 1315683
I have since solved the problem, but in a simpler way. But in your method, where do I intercept that message? And which message am I looking for?
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1315684
Have a look at ClassWizard.  Select the class representing the window that holds your menu. Find the command ID for the menu item and select it in the left-hand list box, and look for the UPDATE_COMMAND_UI event in the right-hand list box. It'll add an OnUpdateCmdUI() handler to your class.

All MFC applicaitons are normally written this way, as it's almost always far more convenient than remembering to call EnableMenuItem() in all the right places everywhere command availability state changes.

.B ekiM

0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question