[Lazarus] RE : ActiveX control demo

Ludo Brands ludo.brands at free.fr
Mon Jan 23 12:38:25 CET 2012



> -----Message d'origine-----
> De : Volker Schäfer [mailto:ErnstVolkerS at web.de] 
> Envoyé : dimanche 22 janvier 2012 18:13
> À : lazarus at lists.lazarus.freepascal.org; ludo.brands at free.fr
> Objet : Re: [Lazarus] ActiveX control demo
> 
> 
> Dear Lazarus Developers,
> 
> at first, sorry about my bad english.
> 
> I tried to use Mr. Brands importtlv0.4.zip from here: 
> http://bugs.freepascal.org/view.php?id=20958.
> 
> I compiled it with FPC 2.6.0 and converted DesignCad 17 Typelibrary.
> 
> The typlibimporter  works well, but in the first part of the 
> Unit are a 
> lot of warnings that PSafeArray not automatable in 
> IDcadSolidEntitydisp.AddItems and so on.
> 
> But I need PSafeArray for my Project.
> 
> I had a look in VarUtils.pas and ActiveX.pas and I think there are 
> differences between VarUtils on Lazarus and VarUtils on Delphi. And 
> perhaps on ActiveX too.
> 
> Is there a trick to use it? Could you help me?
> 
> Many thanks and best regards
> 
> Volker Schäfer
> 


First of all, a newer version of importtl and typelib is commited in fpc
trunk. Some other bug-fixes where submitted in
http://bugs.freepascal.org/view.php?id=21077.

The PSafeArray warning is only for dispinterface. Most typelibs have both
interface and dispinterface definitions for the same interface.
Dispinterface is using late binding and can use only automatable types.
Using the interface definitions, you have all the advantages of early
binding and you can use PSafeArray directly.

The warning doesn't mean it isn't working. It only means that you have a
"generic" olevariant without any "sub-type" information. The warning is
there to give you what is exactly expected in the olevariant. You can simply
assign a VarArray created with VarArrayCreate to the olevariant. 

In freepascal, to use PSafeArray you use the function VarArrayAsPSafeArray.
Despite the name, this returns a PVarArray which you can cast to PSafeArray
(structures are the same).

Ludo





More information about the Lazarus mailing list