Microsoft KB Archive/244204

= BUG: An ATL event does not fire when the event is defined with an interface alias in Visual C++ 6.0 =

Article ID: 244204

Article Last Modified on 9/30/2005

-

APPLIES TO

 Microsoft ActiveX Template Library 3.0, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q244204

<div class="symptoms_section">

SYMPTOMS
When using IDispEventImpl to sink events in an ATL container, the event does not fire and the IDispatch::Invoke call to fire the event returns S_OK. The event actually fails in the call to ITypeInfo2::GetFuncIndexOfMemId with an HRESULT of 0x8002802B within IDispEventSimpleImpl::Invoke.

<div class="cause_section">

CAUSE
A dispinterface may be defined by explicitly listing the set of supported methods and properties or by listing a single interface. Both methods are shown here. [   [attributes] ] dispinterface dispinterface-name {   properties: property-list methods: method-list };

[   [attributes] ] dispinterface dispinterface-name {   interface interface-name }; The symptoms described occur if the event interface that the container is trying to provide a sink for is defined by listing a single interface.

<div class="resolution_section">

RESOLUTION
Define the event interface, that uses IDispEventImpl to sink events, by listing the individual properties and methods, or derive the sink object from IDispEventSimpleImpl instead of IDispEventImpl.

For more information about how to use IDispEventSimpleImpl, click the following article number to view the article in the Microsoft Knowledge Base:

194179 AtlEvnt.exe sample shows how to create ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

<div class="moreinformation_section">

Steps to reproduce the behavior
The following steps require modification to files provided by the ATLEvnt sample that is described in the following Microsoft Knowledge Base article:

194179 AtlEvnt.exe sample shows how to create ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes

<ol>  Open the EventSrc.idl file and change the definition so it looks like this. // EventSrc.idl : IDL source for EventSrc.dll //

// This file will be processed by the MIDL tool to // produce the type library (EventSrc.tlb) and marshalling code.

import "oaidl.idl"; import "ocidl.idl"; [       object, uuid(476D8D1B-381B-11D2-A610-00AA00C14AF9), dual, helpstring("ISrcObj Interface"), pointer_default(unique) ]   interface ISrcObj : IDispatch {   };

[   uuid(476D8D0F-381B-11D2-A610-00AA00C14AF9), version(1.0), helpstring("EventSrc 1.0 Type Library") ] library EVENTSRCLib {   importlib("stdole32.tlb"); importlib("stdole2.tlb"); [       object, uuid(ADF41C66-7795-11d3-9045-0008C76BD9D2), oleautomation, helpstring("_IMyEvents Interface"), pointer_default(unique) ]   interface _IMyEvents : IUnknown {       [id(1), helpstring("method Tick")] HRESULT Tick([in] long tckcnt); };    [        uuid(7F3F60C1-381E-11d2-A610-00AA00C14AF9) ]

dispinterface _EventSink {       interface _IMyEvents; /*     properties: methods: [id(1), helpstring("method Tick")] HRESULT Tick([in] long tckcnt); }

[       uuid(476D8D1C-381B-11D2-A610-00AA00C14AF9), helpstring("SrcObj Class") ]   coclass SrcObj {       [default] interface ISrcObj; [default, source] dispinterface _EventSink; }; };                       </li> Rebuild the EventSrc object.</li> Set ATLEvnt as the active project and rebuild the ATLEvnt.exe file.</li> Run ATLEvnt.Exe, and click the buttons to connect to each sink. Notice that the two event sinks (CSinkObj and CSinkObj2) that derive from IDispEventImpl are not get fired correctly. However, the two event sinks (CSinkObj3 and CSinkObj4) that derive from IDispEventSimpleImpl are fired correctly.</li></ol>

Additional query words: 8002802B

Keywords: kbtshoot kbbug kbidl kbactivexevents KB244204

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.