IDispEventImpl provides a way of implementing an event dispinterface without requiring you to supply implementation code for every method/event on that interface. IDispEventImpl provides implementations of the IDispatch methods. You only need to supply implementations for the events that you are interested in handling.
IDispEventImpl works in conjunction with the event sink map in your class to route events to the appropriate handler function. To use this class:
Add a SINK_ENTRY or SINK_ENTRY_EX macro to the event sink map for each event on each object that you want to handle. When using IDispEventImpl as a base class of a composite control, you can call AtlAdviseSinkMap to establish and break the connection with the event sources for all entries in the event sink map. In other cases, or for greater control, call DispEventAdvise to establish the connection between the source object and the base class. Call DispEventUnadvise to break the connection.
You must derive from IDispEventImpl (using a unique value for nID) for each object for which you need to handle events. You can reuse the base class by unadvising against one source object then advising against a different source object, but the maximum number of source objects that can be handled by a single object at one time is limited by the number of IDispEventImpl base classes.
IDispEventImpl provides the same functionality as IDispEventSimpleImpl, except it gets type information about the interface from a type library rather than having it supplied as a pointer to an _ATL_FUNC_INFO structure. Use IDispEventSimpleImpl when you do not have a type library describing the event interface or want to avoid the overhead associated with using the type library.
Note |
|---|
| IDispEventImpl and IDispEventSimpleImpl provide their own implementation of IUnknown::QueryInterface enabling each IDispEventImpl and IDispEventSimpleImpl base class to act as a separate COM identity while still allowing direct access to class members in your main COM object. |
CE ATL implementation of ActiveX event sinks only supports return values of type HRESULT or void from your event handler methods; any other return value is unsupported and its behavior is undefined.
For more information, see Supporting IDispEventImpl.