Solved

Menu Items are disabled. MFC?

Posted on 2003-11-10
1
740 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
ID: 9717014
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 106
sameEnds challenge 3 135
notReplace  challenge 53 116
java ^ examples 8 62
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

864 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

24 Experts available now in Live!

Get 1:1 Help Now