Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

In my MFC program, Im trying to disable a menu item with EnableMenuItem(), but it doesn have any effect on the menu. Why?

disable menu MFC program
0
Posted

In my MFC program, Im trying to disable a menu item with EnableMenuItem(), but it doesn have any effect on the menu. Why?

0

MFC uses its own system for enabling and disabling menu items and toolbar buttons, which overrides any calls you make to EnableMenuItem(). If you look in the message map of your CMainFrame class, you may see some ON_UPDATE_COMMAND_UI() macros. Those macros control when menu items and toolbar buttons are enabled and disabled. To add a macro for the menu item you want to disable, go to ClassWizard and click the Message Maps tab. In the Class name combo box, select the class where you want to add the handler (usually CMainFrame is a good choice, but for items that relate to data stored in your document, pick your CDocument-derived class instead). In the Object IDs list, select the command ID of the menu item, then in the Messages list, double-click UPDATE_COMMAND_UI.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123