COM: Interface Implementation question 
Author Message
 COM: Interface Implementation question

Hi folks,

I am working on a tool that integrates Dolphin with Visio 2000. In order
to get events from Visio I had to define/implement a Sink interface as
the addAdvise() implemented by Visio (actually many of their components)
requires references to this interface (for now on: IVisioSink).
IVisioSink has one method
#VisEventProc:ipSource:dwEventID:dwSeq:ipSubject:VextraInfo:
IVisioSink is subclass of IDispatch...  

I defined IVisioSink with the ATL wizard, and I used the ActiveX
Component Wizard for uploading the .tlb and generating the IVisioSink
class in my image  (which it was really useful).
Then I started working on the implementation of IVisioSink that is
VisioSink. VisioSink is a subclass of COMInterfaceImp. VisioSink finally
had to implement the following methods:
#supportedInterfaces - which is clear why it is needed from
#GetIDsOfNames:rgszNames:cNames:lcid:rgdispid:
#Invoke:riid:lcid:wFlags:pdispparams:pvarResult:pexcepinfo:puArgErr:
and of course:
#VisEventProc:ipSource:dwEventID:dwSeq:ipSubject:VextraInfo:
The implementation of
#GetIDsOfNames:rgszNames:cNames:lcid:rgdispid:
#Invoke:riid:lcid:wFlags:pdispparams:pvarResult:pexcepinfo:puArgErr:

are borrowed from AXDualImp... It is almost clear that I should make
VisioSink subclass of AXDualImp. Does it means that any implementation
of an IDispatch interface has to be a subclass of AXDualImp? I did get
that idea from the dolphin-wiki pages... Am I doing something wrong?

Thanks! Federico



Sat, 28 Aug 2004 23:40:00 GMT  
 COM: Interface Implementation question

Quote:
> ...
> I am working on a tool that integrates Dolphin with Visio 2000. In order
> to get events from Visio I had to define/implement a Sink interface as
> the addAdvise() implemented by Visio (actually many of their components)
> requires references to this interface (for now on: IVisioSink).
> IVisioSink has one method
> #VisEventProc:ipSource:dwEventID:dwSeq:ipSubject:VextraInfo:
> IVisioSink is subclass of IDispatch...
>...
> It is almost clear that I should make
> VisioSink subclass of AXDualImp.

Yes, that would probably be a good idea. When implementing a "dual"
interface with a type library, the OS provides an efficient implementation
of the IDispatch side of the interface using the information in the type
library. AXDualImp just hooks into that. All you need do is to implement the
custom methods, in this case
#VisEventProc:ipSource:dwEventID:dwSeq:ipSubject:VextraInfo:, and AXDualImp
provides the implementation of all the other IDispatch methods such that if
an invocation is received via IDispatch, it will be forwarded on to your the
custom method.

Quote:
>...Does it means that any implementation
> of an IDispatch interface has to be a subclass of AXDualImp? I did get
> that idea from the dolphin-wiki pages... Am I doing something wrong?

No. In fact most event interfaces are not dual, but just pure
"dispinterfaces". This is (or was) due to a limitation in VB, that may or
may not exist anymore - basically it could only receive events through
IDispatch. These days the same limitation almost certainly applies in most
scripting languages, so event interfaces are usually still just
dispinterfaces. However Dolphin can use and implement vtbl-based "custom"
interfaces (or the vtbl part of a dual interface) much more efficiently, so
this should be used in preference if available.

Regards

Blair



Sun, 29 Aug 2004 17:41:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. newbie question: implementation inheritance and interface specifications in Haskell 98

2. Inheritance: Interface vs Implementation (was: Questions on inheritance)

3. EiffelCOM Question re: ARRAYS in COM Interface...

4. win32com question using R com interface

5. how to register COM interface from python COM-server

6. Implementation of a COM Server with Dolphin 5XP

7. Com implementation of the EAI

8. Does anybody know a _really_working_ implementation of COM

9. Looking for Interface Inheritance Implementation

10. technical implementation details in language interface

11. Separating Interface and Implementation

12. interface-implementation separation

 

 
Powered by phpBB® Forum Software