[fpc-pascal] support for using an activex

Roberto Padovani padovani.r at gmail.com
Wed May 25 19:33:39 CEST 2011


2011/5/25 Ludo Brands <ludo.brands at free.fr>:
> The code in article
> http://www.informit.com/articles/article.aspx?p=130494&seqNum=5 goes a long
> way in doing what you want to do. Unit Eventsink does pretty much of the
> legwork. You should remove the procedure register since that is the Delphi
> way to get a component on the toolbar. Remove also the {$IFDEF VER100} and
> {$ENDIF}. The unit actually includes the code for InterfaceConnect!!

found that! great!


> As for the tlb conversion, in your case
>
> IEventIntfEvents = dispinterface
>  ['{168F5642-5751-49F5-9AA4-B8A7A5F6A5B8}']
>  end;
>
> should do (that is for the events part). AFAIK the procedure and dispid
> definitions are only needed for the server. You are only concerned with
> dispid's. No need to create prototypes for OnCommChanged() etc.
> EventSink1Invoke would be a simple
> case DispID of
>  1: // do CommChanged
>  2: // do StatesChanged
> ...
> end;
>
>

Now I am "wasting" time making the tlb pascal definitions.
For the event part I'm fine with the dispid's
Until now I was calling the activex method with variants, in and out,
but now I discovered that this IDevice class has a property like:
property Sensors: ISensors;
which inside is a list of items like   Sensor: ISensor.

Can I read the sensores with a variant? Then, to see the fields inside
each sensor, I think a I need a class to do that...
The activex has all of these classes with the suitable dispinterfaces
and uuids and so on. But if I define
     var device, transducers, transducer : variant;
and create
     device := CreateOleObject('Device');
then, can i simply write the following ?
     transducers := device.Transducers;
     transducer := transducers[index];


It's a long path until I get this stuff working...

R#



More information about the fpc-pascal mailing list