command is a special type of message. Windows generates a command whenever
user chooses a menu item, clicks a button or tells the system to do
something. Windows send a WM_COMMAND message for menu choices, button clicks
or WM_NOTIFY for list box selection. Commands and notifications are passed
around by the operating system just like any other message until they get
into the top of OnWndMsg() and MFC command routing starts.
messages have the first parameter, the resource id of the menu item that was
chosen or the button that was clicked.
routing is a mechanism used by OnWndMsg to send commands to objects that
can?t receive messages. Only objects of type CWnd can receive messages but
all objects that inherit from CCmdTarget including CWnd and CDocument can
receive commands and notifications.
do commands and notifications get to the class though? The answer is by
command routing. OnWndMsg calls CWnd::OnCommand() or CWnd::OnNotify() which
in turn call OnCmdMsg() which is a virtual function, which means that
different command targets have different implementations. The implementation
of a frame window sends the commands to its views and documents. This is how
commands get handled by m