Solved

Menu Items are disabled. MFC?

Posted on 2003-11-10
1
750 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
difference between String.subString() and String.subSequence() 6 193
sumHeights  challenge 17 70
Excel file not created as expected 7 70
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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