[fpc-pascal] support for using anactivex
Roberto Padovani
padovani.r at gmail.com
Mon May 30 16:30:08 CEST 2011
With the round bracket item := items.item(1);
it crasches saying "Cannot find member"
I am declaring only variants as you suggested....maybe for collections
I have to declare explicitely some interfaces? I tried without
success, but not knowing COM at all, I might have written something
wrong.
I've seen around variants and olevariants...??
Could it be an error or non-standard implementation of the dll ?
I'm loosing confidence.....
Thanks anyway!!
R#
2011/5/30 Ludo Brands <ludo.brands at free.fr>:
> Use Item(i). Item(long Index, [out, retval] ITransducer* *pVal); means
> method with 1 input Index and Output Itransducer^.
>
> Ludo
>
>> -----Message d'origine-----
>> De : fpc-pascal-bounces at lists.freepascal.org
>> [mailto:fpc-pascal-bounces at lists.freepascal.org] De la part
>> de Roberto Padovani
>> Envoyé : lundi 30 mai 2011 14:16
>> À : FPC-Pascal users discussions
>> Objet : Re: RE : RE : RE : RE : RE : RE : [fpc-pascal]
>> support for using anactivex
>>
>>
>> Hi Ludo,
>>
>> I really cannot get the items to work. I simplyfied the
>> source code to the minimum in order to test the items stuff.
>>
>> var obj, item, items : variant;
>>
>> obj := CreateOleObject('WRGactiveX.Device'); // OK
>> items := obj.Transducers; // OK
>> writeln('Count: ', items.Count); // OK ,
>> always prints 8
>>
>> item := items.item[1]; // Crash: EOleSysError : Numero di
>> parametri non valido.
>>
>> Where the exception comment translates to "wrong number of
>> parameters". Instead, writing item := items[1] gives the
>> exception EVariantInvalidArgError : Invalid argument: Dispatch
>>
>> In the activex source code I hav these interface declarations:
>>
>> interface ITransducer : IDispatch
>> {
>> [propget, id(1), helpstring("property Name")]
>> HRESULT Name([out, retval] BSTR *pVal);
>> [propget, id(2), helpstring("property Status")]
>> HRESULT Status([out, retval] WRG_TransdStatus *pVal);
>> [propget, id(4), helpstring("property Meas")]
>> HRESULT Meas([out, retval] double *pVal);
>> };
>>
>> interface ITransducers : IDispatch
>> {
>> [propget, id(1), helpstring("property Count")]
>> HRESULT Count([out, retval] long *pVal);
>> [propget, id(DISPID_VALUE),
>> helpstring("property Item")] HRESULT Item(long Index, [out,
>> retval] ITransducer* *pVal);
>> [propget, id(DISPID_NEWENUM),
>> helpstring("property _NewEnum"), hidden] HRESULT
>> _NewEnum([out, retval] LPUNKNOWN *pVal);
>> };
>>
>> and used inside the IDevice class like:
>>
>> [propget, id(21), helpstring("property
>> Transducers")] HRESULT Transducers([out, retval] ITransducers* *pVal);
>>
>>
>> I would be very grateful if you could help me once more.
>>
>> Roberto
>>
>>
>>
>> 2011/5/25 Ludo Brands <ludo.brands at free.fr>:
>> > Using variants you can transparently "walk" along the
>> exposed objects.
>> > The variant contains the Idispatch of the object and gets
>> the exposed
>> > methods at runtime. Properties are implemented as get and
>> put methods
>> > or just get methods for read only properties.
>> >
>> > If you have something like
>> > Itransducers = interface
>> > ..
>> > property transducer[Index:integer]:Itransducer;
>> > end;
>> >
>> > Then you would do
>> > transducer := transducers.transducer[index];
>> >
>> > transducer := transducers[index]; works only if transducer is the
>> > default property for Itransducers. I'm not sure if fpc
>> supports this.
>> >
>> > Ludo
>> >
>> >
>> > -----Message d'origine-----
>> > De : fpc-pascal-bounces at lists.freepascal.org
>> > [mailto:fpc-pascal-bounces at lists.freepascal.org] De la part
>> de Roberto
>> > Padovani Envoyé : mercredi 25 mai 2011 19:34
>> > À : FPC-Pascal users discussions
>> > Objet : Re: RE : RE : RE : RE : RE : [fpc-pascal] support
>> for using an
>> > activex
>> >
>> >
>> > 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#
>> > _______________________________________________
>> > fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>> >
>> > _______________________________________________
>> > fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>> >
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list