|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
CCmdUI does not have a base class.
The CCmdUI class is used only within an ON_UPDATE_COMMAND_UI handler in a CCmdTarget-derived class.
When a user of your application pulls down a menu, each menu item needs to know whether it should be displayed as enabled or disabled. The target of a menu command provides this information by implementing an ON_UPDATE_COMMAND_UI handler. For each of the command user-interface objects in your application, use the Properties window to create a message-map entry and function prototype for each handler.
When the menu is pulled down, the framework searches for and calls each ON_UPDATE_COMMAND_UI handler, each handler calls CCmdUI member functions such as Enable and Check, and the framework then appropriately displays each menu item.
A menu item can be replaced with a control-bar button or other command user-interface object without changing the code within the ON_UPDATE_COMMAND_UI handler.
The following table summarizes the effect CCmdUI's member functions have on various command user-interface items.
|Menu item||Enables or disables||Checks (×) or unchecks||Checks using dot (•)||Sets item text|
|Toolbar button||Enables or disables||Selects, unselects, or indeterminate||Same as SetCheck||(Not applicable)|
|Status-bar pane||Makes text visible or invisible||Sets pop-out or normal border||Same as SetCheck||Sets pane text|
|Normal button in CDialogBar||Enables or disables||Checks or unchecks check box||Same as SetCheck||Sets button text|
|Normal control in CDialogBar||Enables or disables||(Not applicable)||(Not applicable)||Sets window text|
For more on the use of this class, see How to Update User-Interface Objects.