 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Sam Guest
|
Posted: Tue Nov 18, 2003 1:39 pm Post subject: Delphi Record types in VC++ |
|
|
Hi,
How do I pass records as arguments in an ActiveX Control. I have the
following record which I've created in the Type Library:
xRect = record
Left,
Top,
Right,
Bottom: Double
end;
And, my method for accepting it as argument is as follows:
procedure Method1(aRect: xRect); safecall;
This ActiveX works perfectly when imported and used in Delphi! BUT, when I
tried it in Visual C++ 6.0, .... this method is not exposed.
When I checked in the header file, I found the following commented statement
instead of the method:
"// method 'Method1' not emitted because of invalid return type or parameter
type"
Why is this happening? How do I expose the Record (strut) types in VC++?
Thanks in advance.
--
Sam
|
|
| Back to top |
|
 |
Brian Cook Guest
|
Posted: Tue Nov 18, 2003 5:28 pm Post subject: Re: Delphi Record types in VC++ |
|
|
Greetings.
| Quote: | Why is this happening?
|
Delphi probably passes records differently than Visual C.
| Quote: | How do I expose the Record (strut) types in VC++?
|
Make the parameter a "const". It should be treated as a "pointer to a
structure" in Visual C...
procedure Method1( const aRect: xRect ); safecall;
If "const" doesn't work you will have to declare the parameter as a
pointer to a record...
type
PRect = ^xRect;
procedure Method1( aRect: PRect ); safecall;
Good luck, Brian
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Wed Nov 19, 2003 6:36 am Post subject: Re: Delphi Record types in VC++ |
|
|
Hi,
| Quote: | Make the parameter a "const". It should be treated as a "pointer to a
structure" in Visual C...
procedure Method1( const aRect: xRect ); safecall;
|
How can I give this in a Type Library? If the type is given as WideString,
delphi automatically takes it as 'const'. But how do I specify a record to
be taken as 'const'?
| Quote: | If "const" doesn't work you will have to declare the parameter as a
pointer to a record...
type
PRect = ^xRect;
procedure Method1( aRect: PRect ); safecall;
|
This too can't be specified exactly in a Type Library. But I tried giving it
as 'var' parameter, which didn't make any difference in VC++.
procedure Method1(var aRect: xRect); safecall;
Still the above method gets omitted in VC++.
Thanks,
--
Sam.
"Brian Cook" <bcook@rowdydogsoftware[REMOVE].com> wrote
| Quote: | Hi,
Greetings.
Why is this happening?
Delphi probably passes records differently than Visual C.
How do I expose the Record (strut) types in VC++?
Make the parameter a "const". It should be treated as a "pointer to a
structure" in Visual C...
procedure Method1( const aRect: xRect ); safecall;
If "const" doesn't work you will have to declare the parameter as a
pointer to a record...
type
PRect = ^xRect;
procedure Method1( aRect: PRect ); safecall;
Good luck, Brian
|
|
|
| Back to top |
|
 |
Brian Cook Guest
|
Posted: Wed Nov 19, 2003 7:08 am Post subject: Re: Delphi Record types in VC++ |
|
|
Greetings.
| Quote: | Make the parameter a "const". It should be treated as a "pointer to a
structure" in Visual C...
procedure Method1( const aRect: xRect ); safecall;
How can I give this in a Type Library? If the type is given as WideString,
delphi automatically takes it as 'const'. But how do I specify a record to
be taken as 'const'?
|
I have no idea. I just assumed it was possible.
| Quote: | If "const" doesn't work you will have to declare the parameter as a
pointer to a record...
type
PRect = ^xRect;
procedure Method1( aRect: PRect ); safecall;
This too can't be specified exactly in a Type Library.
|
Really? Obviously, I went crazy with assumptions. This time I assumed
pointers would always be usable in a type-library. I'm sorry for
leading you astray and embarrassed and the quantity of bad advice I've
delivered!
| Quote: | But I tried giving it as 'var' parameter, which didn't make any
difference in VC++.
procedure Method1(var aRect: xRect); safecall;
Still the above method gets omitted in VC++.
|
The only other thing I can think of is to declare Method1 to take a
generic pointer...
procedure Method1( aRect: Pointer ); safecall;
....in which case you'll have to perform a type-cast...
PRect(aRect)^.Left := 13;
....and the Visual C side will not be declared correctly; also requiring
a type-cast.
Good luck, Brian
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Wed Nov 19, 2003 11:21 am Post subject: Re: Delphi Record types in VC++ |
|
|
Anybody has any solution to this problem?
--
Sam.
"Sam" <anishsam (AT) gnostice (DOT) com> wrote
| Quote: | Hi,
How do I pass records as arguments in an ActiveX Control. I have the
following record which I've created in the Type Library:
xRect = record
Left,
Top,
Right,
Bottom: Double
end;
And, my method for accepting it as argument is as follows:
procedure Method1(aRect: xRect); safecall;
This ActiveX works perfectly when imported and used in Delphi! BUT, when I
tried it in Visual C++ 6.0, .... this method is not exposed.
When I checked in the header file, I found the following commented
statement
instead of the method:
"// method 'Method1' not emitted because of invalid return type or
parameter
type"
Why is this happening? How do I expose the Record (strut) types in VC++?
Thanks in advance.
--
Sam
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|