[fpc-pascal] support for using an activex

Ludo Brands ludo.brands at free.fr
Wed May 25 14:31:54 CEST 2011

Interfaceconnect calls Advice on the objects IConnectionPoint. I can't share
Delphi code here but essentially what you do is:

Get IConnectionPointContainer (CPC) from IUnknown (ActiveXObject) :
  ActiveXObject.QueryInterface(IConnectionPointContainer, CPC);

Get IConnectionPoint (ppcp) for the IID of interest (RIID) from
IConnectionPointContainer :
  CPC.FindConnectionPoint(RIID, ppcp);

Call Advice on IConnectionPoint (ppcp) with the sink interface you created :
  CP.Advise(unkSink, dwCookie);

That's it!  Keep hold of dwCookie as it is used to disconnect later on:


-----Message d'origine-----
De : fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] De la part de Roberto
Envoyé : mercredi 25 mai 2011 13:18
À : FPC-Pascal users discussions
Objet : Re: RE : RE : RE : [fpc-pascal] support for using an activex

2011/5/24 Ludo Brands <ludo.brands at free.fr>:
> The following delphi articles should help creating an event sink:
> http://www.informit.com/articles/article.aspx?p=130494&seqNum=5  This 
> is an interesting one since it is written for Delphi 3-4 which missed 
> a lot of the automated COM handling. This is much closer to where fpc 
> is now.
> http://www.blong.com/Conferences/IConUK2000/DelphiMoreAutomation/More%
> 20Auto
> mation%20In%20Delphi.htm#HandcraftedEventSink
> A good intruduction to connectable objects: 
> http://www.gtro.com/delphi/comevents_e.php

Thanks a lot!

I'm reading it all and writing some code.
But in all of those docs there the "InterfaceConnect" routine is used....but
I can't find it anywhere. Besides, is there something to convert the tlb to
pascal? Or shall I do it manually?

I might be wrong, but it seems to me that it should be possible to write a
general TSimpleEventSink class which does most of all the COM work, and
exposes a pascal-standard event management. The TSimpleEventSink class might
have an Events property which is a dynamic array of TNotifyEvents; the
client could resize it and link its event handlers. At the same time the
TSimpleEventSink reacts to the server events by mapping the dispid's to the
Events array index, up to its current maximum dimension.

Well, I'm still quite confused.... besides the missing InterfaceConnect
method, is there any freepascal example available? On the web I can only
find delphi ones.


fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org

More information about the fpc-pascal mailing list