[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Menu Items are disabled. MFC?

Posted on 2003-11-10
1
Medium Priority
?
857 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 480 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 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