class CDynamicChain
CDynamicChain manages a collection of message maps, enabling a Windows message to be directed, at run time, to another object’s message map.
To add support for dynamic chaining of message maps, do the following:
For example, suppose your class is defined as follows:
class CMyWindow : public CDynamicChain, ...
{
public:
...
BEGIN_MSG_MAP(CMyWindow)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
// dynamically chain to the default
// message map in another object
CHAIN_MSG_MAP_DYNAMIC(1313)
// '1313' identifies the object
// and the message map that will be
// chained to. '1313' is defined
// through the SetChainEntry method
END_MSG_MAP()
LRESULT OnPaint(UINT uMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
{ ... }
LRESULT OnSetFocus(UINT uMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
{ ... }
};
The client then calls CMyWindow::SetChainEntry
:
// myCtl is a CMyWindow object
myCtl.SetChainEntry(1313, &chainedObj);
where chainedObj
is the chained object and is an instance of a class derived from CMessageMap. Now, if myCtl
receives a message that is not handled by OnPaint
or OnSetFocus
, the window procedure directs the message to chainedObj
’s default message map.
For more information about message map chaining, see Message Maps in the article “ATL Window Classes.”
#include <atlwin.h>
See Also CWindowImpl