?
Solved

What is wrong with this parameter for receiving data from an ActiveX control

Posted on 2003-03-19
10
Medium Priority
?
174 Views
Last Modified: 2010-04-04
In the *_TLB ... is a control function

function A(const s: widestring; b: boolean;
   out object: IDispatch): wordbool; dispid 9;

I define a object (defined in the control as the received data object) in my app to receive data:-

var st: AnObject;

I call it with:-

control:=CreateComObject(......);
flag:=control.A('string',false,st as AnObject);

and I get compile error for the 'st' parameter:-

'Type of actual and formal var parameters must be identical'

Can anybody help as I'm sure there's a simple answer?

Regards,
Steve.
0
Comment
Question by:snells
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 9

Expert Comment

by:mocarts
ID: 8166673
must be:
var
  st: IUnknown;

as in function declaration or var st must be an object which implements IUnknown interface.

wbr, mo.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8166691
correction :)
as this is an out parameter then there can be only interface type variable.
mo.
0
 

Author Comment

by:snells
ID: 8166779
Thanx mo, quick reply.

So I make it:-

var st: IDispatch;

... and then change code to:-

flag:=control.A('string',false,st);
string:=AnObject(st).title;

Is this the right way to do it?

Regards,
Steve.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:mocarts
ID: 8166820
no, this will not work anyway.
you should use interface to get Title. check your _TLB for an interface which is implemented (directly or indirectly) by AnObject (take a look how Title is received in AnObject)
mo.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8166829
so all code must be something like:

var
  st: IAnObject; // interface type
begin
  flag := control.A('string', false, st);
  string := st.Title;
end;
0
 

Author Comment

by:snells
ID: 8167002
var
 st: IAnObject; // interface type
begin
 flag := control.A('string', false, st);

... This still brings up the same compile error as before.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8167142
control.A('string', false, IUnknown(st));
should compile this line.

but declaration of A is strange with it parameter name object (reserved word).. at least in my D5 function with such parameter name don't compiles.

mo.
0
 

Author Comment

by:snells
ID: 8167330
function A(const s: widestring; b: boolean;
  out object: IDispatch): wordbool; dispid 9;

.. is not the real function declaration it's ...

function GetImageIPTC_Info(const ImageName: widestring; FavorPhotoshopIPTC: wordbool;
  out IPTC_Info: IDispatch): wordbool; dispid 9;

... IPTC_Info is an object with methods/props etc.

... and I'm using Delphi7 ... so things may work differently to 5.

0
 

Author Comment

by:snells
ID: 8167421
function A(const s: widestring; b: boolean;
  out object: IDispatch): wordbool; dispid 9;

.. is not the real function declaration it's ...

function GetImageIPTC_Info(const ImageName: widestring; FavorPhotoshopIPTC: wordbool;
  out IPTC_Info: IDispatch): wordbool; dispid 9;

... IPTC_Info is an object with methods/props etc.

... and I'm using Delphi7 ... so things may work differently to 5.

0
 
LVL 9

Accepted Solution

by:
mocarts earned 300 total points
ID: 8167938
sorry, you must cast to IDispatch (I think you figured out that :)
control.A('string', false, IDispatch(st));

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question