The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

Creates an event source.

      [ event_source(  
   optimize=[speed | size],  
   decorate=[true | false]  
) ]  


An enumeration of one of the following values:

  • native for unmanaged C/C++ code (default for unmanaged classes).

  • com for COM code. You must use coclass when type=com. This value requires that you include the following header files:

    #define _ATL_ATTRIBUTES  
    #include <atlbase.h>  
    #include <atlcom.h>  

When type is native, you can specify optimize=size, to indicate that there is 4 bytes of storage (minimum) for all events in a class or optimize=speed (the default) to indicate that there is 4 * (# of events) bytes of storage.

When type is native, you can specify decorate=false, to indicate that the expanded name in the merged (.mrg) file should not include the enclosing class name. /Fx lets you generate .mrg files. decorate=false, which is the default, results in fully-qualified type names in the merged file.

The event_source C++ attribute specifies that the class or structure to which it is applied will be an event source.

event_source is used in conjunction with the event_receiver attribute and the __event keyword. Use event_receiver to create event receivers. Use __event on methods within the event source to specify those methods as events.

System_CAPS_ICON_note.jpg Note

A templated class or struct cannot contain events.

Attribute Context

Applies toclass, struct
Required attributescoclass when type=com
Invalid attributesNone

For more information, see Attribute Contexts.

Compiler Attributes
Class Attributes
Attributes Samples