Command Routing Classes

As the user interacts with the application by choosing menus or control-bar buttons with the mouse, the application sends messages from the affected user-interface object to an appropriate command-target object. Command-target classes derived from CCmdTarget include CWinApp, CWnd, CDocTemplate, CDocument, CView, and the classes derived from them. The framework supports automatic command routing so that commands can be handled by the most appropriate object currently active in the application.

An object of class CCmdUI is passed to your command targets’ update command UI (ON_UPDATE_COMMAND_UI) handlers to allow you to update the state of the user interface for a particular command (for instance, to check or remove the check from menu items). You call member functions of the CCmdUI object to update the state of the UI object. This process is the same whether the UI object associated with a particular command is a menu item or a button or both.

CCmdTarget

Serves as the base class for all classes of objects that can receive and respond to messages.

CCmdUI

Provides a programmatic interface for updating user-interface objects such as menu items or control-bar buttons. The command target object enables, disables, checks, and/or clears the user-interface object via this object.