CHAIN_MSG_MAP
Defines an entry in a message map.
CHAIN_MSG_MAP( theChainClass )
Parameters
- theChainClass
[in] The name of the base class containing the message map.
Remarks
CHAIN_MSG_MAP directs messages to a base class's default message map (declared with BEGIN_MSG_MAP). To direct messages to a base class's alternate message map (declared with ALT_MSG_MAP), use CHAIN_MSG_MAP_ALT.
注意
Always begin a message map with BEGIN_MSG_MAP. You can then declare subsequent alternate message maps with ALT_MSG_MAP. The END_MSG_MAP macro marks the end of the message map. Every message map must have exactly one instance of BEGIN_MSG_MAP and END_MSG_MAP.
For more information about using message maps in ATL, see Message Maps.
Example
class CMyExtClass : public CMyBaseClass
{
public:
BEGIN_MSG_MAP(CMyExtClass)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
// chain to default message map in CMyBaseClass
CHAIN_MSG_MAP(CMyBaseClass)
ALT_MSG_MAP(1)
// chain to first alternative message map in CMyBaseClass
CHAIN_MSG_MAP(CMyBaseClass)
ALT_MSG_MAP(2)
MESSAGE_HANDLER(WM_CHAR, OnChar)
// chain to alternate message map in CMyBaseClass
CHAIN_MSG_MAP_ALT(CMyBaseClass, 1)
END_MSG_MAP()
LRESULT OnPaint(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
BOOL& /*bHandled*/)
{
return 0;
}
LRESULT OnChar(UINT /*nMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
BOOL& /*bHandled*/)
{
return 0;
}
};
This example illustrates the following:
If a window procedure is using CMyClass's default message map and OnPaint does not handle a message, the message is directed to CMyBaseClass's default message map for processing.
If a window procedure is using the first alternate message map in CMyClass, all messages are directed to CMyBaseClass's default message map.
If a window procedure is using CMyClass's second alternate message map and OnChar does not handle a message, the message is directed to the specified alternate message map in CMyBaseClass. CMyBaseClass must have declared this message map with ALT_MSG_MAP(1).
Requirements
Header: atlwin.h