IDispEventImpl Class
This class provides implementations of the IDispatch methods.
template <
UINT nID,
class T,
const IID* pdiid = &IID_NULL,
const GUID* plibid = &GUID_NULL,
WORD wMajor = 0,
WORD wMinor = 0,
class tihclass = CcomTypeInfoHolder
>
class ATL_NO_VTABLE IDispEventImpl :
public IDispEventSimpleImpl<nID, T, pdiid>
Parameters
nID
A unique identifier for the source object. When IDispEventImpl is the base class for a composite control, use the resource ID of the desired contained control for this parameter. In other cases, use an arbitrary positive integer.T
The user's class, which is derived from IDispEventImpl.pdiid
The pointer to the IID of the event dispinterface implemented by this class. This interface must be defined in the type library denoted by plibid, wMajor, and wMinor.plibid
A pointer to the type library that defines the dispatch interface pointed to by pdiid. If &GUID_NULL, the type library will be loaded from the object sourcing the events.wMajor
The major version of the type library. The default value is 0.wMinor
The minor version of the type library. The default value is 0.tihclass
The class used to manage the type information for T. The default value is a class of type CComTypeInfoHolder; however, you can override this template parameter by providing a class of a type other than CComTypeInfoHolder.
Remarks
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.
Hinweis
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.
Requirements
Header: atlcom.h