DECLARE_EVENTSINK_MAP An OLE container can provide an event sink map to specify the events your container will be notified of.用法跟BEGIN_MESSAGE_MAP作用差不多
An OLE container can provide an event sink map to specify the events your container will be notified of. DECLARE_EVENTSINK_MAP( ) Res Use the DECLARE_EVENTSINK_MAP macro at the end of your class declaration. Then, in the .CPP file that defines the member functions for the class, use the BEGIN_EVENTSINK_MAP macro, macro entries for each of the events to be notified of, and the END_EVENTSINK_MAP macro to declare the end of the event sink list. For more information on event sink maps, see the article ActiveX Control Containers.
#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
PTM_WARNING_DISABLE \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return GetThisMessageMap(); } \
const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
{ \
typedef theClass ThisClass; \
typedef baseClass TheBaseClass; \
static const AFX_MSGMAP_ENTRY _messageEntries[] = \
{
DECLARE_EVENTSINK_MAP()放在控件容器类的头文件中,比如说放在一个CMyView类的头文件中。
在相应的实现文件中,用
BEGIN_EVENTSINK_MAP(CMyView, CWnd)和END_EVENTSINK_MAP()对包起一组控件事件处理函数宏。
这几个宏可以不用自己写,在vs2005中引入activex控件,用IDE处理控件事件会自动产生这些代码,你只要改写相应的事件响应代码就可以了。还是做个测试例子,看一下Vs生成的源码就明白了。
DECLARE_EVENTSINK_MAP( )
Res
Use the DECLARE_EVENTSINK_MAP macro at the end of your class declaration. Then, in the .CPP file that defines the member functions for the class, use the BEGIN_EVENTSINK_MAP macro, macro entries for each of the events to be notified of, and the END_EVENTSINK_MAP macro to declare the end of the event sink list. For more information on event sink maps, see the article ActiveX Control Containers.