我在看串口编辑的书中看到这么一句话 
 DECLARE_EVENTSINK_MAP() //声明串口控件的事件引用宏
 请问高手们 什么是事件引用宏 它在程序中的地位是怎样的 有什么作用呢

解决方案 »

  1.   

    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作用差不多
      

  2.   

    宏只是文本替换,比如说:
    #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[] =  \
    {
      

  3.   

    用在MFC的应用程序中,当应用中使用了activex control并和Activex控件有事件交互时。
    DECLARE_EVENTSINK_MAP()放在控件容器类的头文件中,比如说放在一个CMyView类的头文件中。
    在相应的实现文件中,用
    BEGIN_EVENTSINK_MAP(CMyView, CWnd)和END_EVENTSINK_MAP()对包起一组控件事件处理函数宏。
    这几个宏可以不用自己写,在vs2005中引入activex控件,用IDE处理控件事件会自动产生这些代码,你只要改写相应的事件响应代码就可以了。还是做个测试例子,看一下Vs生成的源码就明白了。
      

  4.   

    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.