• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

GRAYED Menu Items

I am aware of the EnabledMenuItem fuction which takes three parameters.  How to a get the handler of the default menu??
The other two parameters are self explanatory.
  • 2
1 Solution
This is the "MFC Programming Question" area, so I guess the best answer I could give you is to use CMenu, which has its own version of EnableMenuItem. Then you don't need the handle.

CMenu menu;
if (menu.LoadMenu(IDR_MY_MENU))
  menu.EnableMenuItem(nIDEnableItem, nEnable);

GetMenu() will return a pointer to the windows menu. (Call this in CMainFrame if you want to get the app manu).
mikeljjAuthor Commented:
piano boxer, can I call this from CView??
You can call GetMenu() from any window, and it will return a pointer to *its* own menu.

But I dont think your CView class has any menu, the menu proberly belongs to CMainFrame.

To get the app's menu from anywhere do this:

CMenu* pMenu = AfxGetMainWnd()->GetMenu();
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now