IDispEventImpl Class


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at IDispEventImpl Class.

This class provides implementations of the IDispatch methods.

System_CAPS_ICON_important.jpg Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

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>


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.

The user's class, which is derived from IDispEventImpl.

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.

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.

The major version of the type library. The default value is 0.

The minor version of the type library. The default value is 0.

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.

Public Typedefs

IDispEventImpl::_tihclassThe class used to manage the type information. By default, CComTypeInfoHolder.

Public Constructors

IDispEventImpl::IDispEventImplThe constructor.

Public Methods

IDispEventImpl::GetFuncInfoFromIdLocates the function index for the specified dispatch identifier.
IDispEventImpl::GetIDsOfNamesMaps a single member and an optional set of argument names to a corresponding set of integer DISPIDs.
IDispEventImpl::GetTypeInfoRetrieves the type information for an object.
IDispEventImpl::GetTypeInfoCountRetrieves the number of type information interfaces.
IDispEventImpl::GetUserDefinedTypeRetrieves the basic type of a user-defined type.

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.

System_CAPS_ICON_note.jpg 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.





Header: atlcom.h

Locates the function index for the specified dispatch identifier.

HRESULT GetFuncInfoFromId(
    const IID& iid,
    DISPID dispidMember,
    LCID lcid,
    _ATL_FUNC_INFO& info);


[in] A reference to the ID of the function.

[in] The dispatch ID of the function.

[in] The locale context of the function ID.

[in] The structure indicating how the function is called.

Return Value

A standard HRESULT value.

Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs, which can be used on subsequent calls to IDispatch::Invoke.

    REFIID riid,
    LPOLESTR* rgszNames,
    UINT cNames,
    LCID lcid,
    DISPID* rgdispid);


See IDispatch::GetIDsOfNames in the Windows SDK.

Retrieves the type information for an object, which can then be used to get the type information for an interface.

    UINT itinfo,
    LCID lcid,
    ITypeInfo** pptinfo);


Retrieves the number of type information interfaces that an object provides (either 0 or 1).

STDMETHOD(GetTypeInfoCount)(UINT* pctinfo);


See IDispatch::GetTypeInfoCount in the Windows SDK.

Retrieves the basic type of a user-defined type.

VARTYPE GetUserDefinedType(
    ITypeInfo* pTI,
    HREFTYPE hrt);


[in] A pointer to the ITypeInfo interface containing the user-defined type.

[in] A handle to the type description to be retrieved.

Return Value

The type of variant.


See ITypeInfo::GetRefTypeInfo.

The constructor. Stores the values of the class template parameters plibid, pdiid, wMajor, and wMinor.


This typedef is an instance of the class template parameter tihclass.

typedef tihclass _tihclass;


By default, the class is CComTypeInfoHolder. CComTypeInfoHolder manages the type information for the class.

_ATL_FUNC_INFO Structure
IDispatchImpl Class
IDispEventSimpleImpl Class
Class Overview