• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • 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.
0
mikeljj
Asked:
mikeljj
  • 2
1 Solution
 
zingoCommented:
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);
}

0
 
piano_boxerCommented:
GetMenu() will return a pointer to the windows menu. (Call this in CMainFrame if you want to get the app manu).
0
 
mikeljjAuthor Commented:
piano boxer, can I call this from CView??
0
 
piano_boxerCommented:
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();
ASSERT_VALID(pMenu);
0
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

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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