Solved

Menu Items are disabled. MFC?

Posted on 2003-11-10
1
724 Views
Last Modified: 2013-11-20
I am new to MFC. I just created a menu (by modifying MFC's default SDI menu). When I test-run the program, a bunch of my newly created menu items (selected seemingly arbitrarily) come out DISABLED. Does anyone know why? I searched the program's files for calls to EnableMenuItem() and found nothing. It's really annoying not to have control over such things. Do I have to overwrite CWnd::OnInitMenuPopup() to prevent this from happening or is there a way to disable this MFC feature without it?
Thanks in advance.  
0
Comment
Question by:abuly80
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 120 total points
Comment Utility
By default menu item in MFC SDI application is disabled if you don't handle it. Once you add menu item handler, menu is enabled. If you want to enable/disable menu item programmatically, handle WM_COMMAND_UI for this item:

void CMainFrame::OnUpdateMenuItem(CCmdUI* pCmdUI)
{
    pCmdUI->Enable(m_bEnabelFlag);
}

m_bEnabelFlag - some variable or condition. Setting it to TRUE enables menu ite, to FALSE - disables.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now