event_receiver

创建一个事件接收器 (接收器)。

[ event_receiver( 
   type 
   [, layout_dependent=false] 
) ]

参数

  • type
    枚举下列值之一:

    • 非托管 C/C++ 代码 (本机类的默认native )。

    • COM 代码的com 。 此值需要包括以下头文件:

         #define _ATL_ATTRIBUTES
         #include <atlbase.h>
         #include <atlcom.h>
      
  • layout_dependent
    指定 layout_dependent ,仅当 type=COMlayout_dependent 布尔值:

    • true 意味着委托的签名事件接收器的必须与它们在事件源挂钩的项。 事件接收器处理程序名称必须与相关事件源接口指定的名称。 必须使用 coclass ,当 layout_dependenttrue。 效率稍高的指定 true

    • 错误 (默认值) 表示调用约定和存储类 (虚方法,静态和其他) 不必与操作方法和处理程序;也不需要名称与事件源接口方法名称的处理程序。

备注

event_receiver C++ 特性指定它是应用的类或结构将为事件接收器,使用 Visual C++ 统一的事件模型,。

event_receiver 使用 event_source 属性和 __hook__unhook 关键字。 使用 event_source 创建事件源。 使用将事件接收器的方法中 __hook 关联 (“挂钩”) 事件接收器方法添加到事件源的事件。 使用 __unhook 取消它们。

layout_dependent 用于 COM 事件接收器 (type=COM) 仅指定。 layout_dependent 的 默认值为 错误

备注

模板类或结构不能包含事件。

要求

属性上下文

适用对象

, struct

可重复

必需的特性

coclass ,当 layout_dependent=true

无效的特性

有关更多信息,请参见 属性上下文

请参见

参考

event_source

__event

__hook

__unhook

其他资源

编译器特性

类特性

Attributes Samples