A, claimed by ScottMcP-MVP MFC, has a menu configuration in the ON_UPDATE_COMMAND_UI handler: when a user pulls a menu, each menu item must know whether it should be displayed as enabled or disabled. The purpose of the menu command is to provide this information by implementing the ON_UPDATE_COMMAND_UI handler. For each of the command UI objects in your application, use the Properties window to create a record and message map for each handler.
When the menu is pulled out, the environment searches for and calls each ON_UPDATE_COMMAND_UI handler, each handler calls CCmdUI member functions such as Enable and Check, and the structure then displays each menu item accordingly.
This means that you must store the expected state for the menu item in your classes, which you can check or uncheck. You will need to place one ON_UPDATE_COMMAND_UI macro in the menu item next to the ON_COMMAND macro, and this item will refer to a function that receives the CCmdUi object, which you can change to suit your needs. But since you use MFC, you usually do not do this manually, but simply use the properties of windows containing menus.
Serge Ballesta
source share