Board index » delphi » Syntax error passing parameter to activeX control

Syntax error passing parameter to activeX control

I am tringy to call a function from an activeX control. No problem with
functions that take are receive simple variables (like integers).

For the function I am interested in the TLB file indicates that the
parameter should be a PSafeArray. When I pass a psafearray the compiler
rejects it at compile time with the Message :" Type not allowed in OLE
Automation call".  (I can pass a variant, but the activeX control gives an
error at runtime)

I am not even concerned yet with initiailizing and reading the array, it
seems to be a simple syntax problem. If the TLB specifies PSafeArray, why
can't I pass a PSafeArray?

 

Re:Syntax error passing parameter to activeX control


<<Martin Lapidus:
When I pass a psafearray the compiler rejects it at
compile time with the Message :" Type not allowed
in OLE Automation call".

Quote

Delphi uses variants for dealing with safearrays.
For example, if you have a control with an
AddThesePlease method that takes a PSafeArray,
it could look like this in the TLB.pas
  IChattyPanelXDisp = dispinterface
    procedure AddThesePlease(IntArray: OleVariant); dispid 34;
   ...

and you could call it like this:

var
  Arr: OleVariant;
  ArrP: PSafeArray;
begin
  Arr := VarArrayOf([1, 2, 3, 4]);
  ArrP := PSafeArray(TVardata(Arr).VArray);
 ChattyPanelX1.AddThesePlease(ArrP);

--
Deborah Pate

Re:Syntax error passing parameter to activeX control


The tlb file shows:

  procedure GetAllChartListSorts(var SortNames: PSafeArray); safecall;
not oleVariant

Quote
>When I pass a psafearray the compiler rejects it at
>compile time with the Message :" Type not allowed
>in OLE Automation call".

>Delphi uses variants for dealing with safearrays.
>For example, if you have a control with an
>AddThesePlease method that takes a PSafeArray,
>it could look like this in the TLB.pas
>  IChattyPanelXDisp = dispinterface
>    procedure AddThesePlease(IntArray: OleVariant); dispid 34;
>   ...

Re:Syntax error passing parameter to activeX control


<<Martin Lapidus:
The tlb file shows:
  procedure GetAllChartListSorts(var SortNames: PSafeArray); safecall;
not oleVariant

Quote

That's clever, I can't even compile with that
as a parameter for an automation interface.
What happens if you change it to OleVariant?
(And is it a Delphi ActiveX, BTW?)

--
Deborah Pate

Other Threads