OnCmdMsg Handler

To accomplish the routing of commands, each command target calls the OnCmdMsg member function of the next command target in the sequence. Command targets use OnCmdMsg to determine whether they can handle a command and to route it to another command target if they cannot handle it.

Each command-target class may override the OnCmdMsg member function. The overrides let each class route commands to a particular next target. A frame window, for example, always routes commands to its current child window or view, as shown in the table Standard Command Route.

The default CCmdTarget implementation of OnCmdMsg uses the message map of the command-target class to search for a handler function for each command message it receives — in the same way that standard messages are searched. If it finds a match, it calls the handler. Message-map searching is explained in How the Framework Searches Message Maps.

See also

How the Framework Calls a Handler