An alternative message map allows you to define message handlers on one map for messages from other windows. Take a look at your map above:
BEGIN_MSG_MAP(CCommandBarCtrlImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_FORWARDMSG, OnForwardMsg) ... ALT_MSG_MAP(1) // Parent window messages MESSAGE_HANDLER(WM_INITMENUPOPUP, OnParentInitMenuPopup) ...
This is the CCommandBarCtrlImpl class, and its associated window handle, HWND , is associated with it. All messages go through the card by default (lines above ALT_MSG_MAP(1) ).
Not for some reason the class wants to process the parent's messages. It subclasses it with a member class variable, and you get to the point where you need to define message handlers. You cannot add them directly to the same card, because it will be a mess with your own window messages.
Alternative maps help here. Messages from the parent window are sent to alternative message card No. 1.
You do not need alternative maps if you only process messages from your window.
source share