 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Sam Guest
|
Posted: Thu Oct 23, 2003 11:20 am Post subject: Help with ActiveX Creation Please! |
|
|
Hi Everybody,
I need some real help to crack this ActiveX problem I'm facing. Please help
me.
Take a look at the following unit/code:
----------------------------------------------------------------------------
--
unit MyClassU;
interface
uses Classes, Controls, Dialogs;
Type
// Helper class for TMyClass, which acts as argument in TMyClass methods.
THelperClass = class(TPersistent)
private
FField1: Integer;
FField2: string;
public
procedure SomePublicProc;
published
property Prop1: Integer read FField1 write FField1;
property Prop2: string read FField2 write FField2;
end;
// Main component class to be converted to ActiveX Control.
TMyClass = class(TWinControl)
private
FClassField: THelperClass;
FIntField: Integer;
public
procedure SetSomeClass(aClass: THelperClass);
function GetSomeClass: THelperClass;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property HelperProp: THelperClass read FClassField write FClassField;
property IntProp: Integer read FIntField write FIntField;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Test', [TMyClass]);
end;
{ TMyClass }
constructor TMyClass.Create(AOwner: TComponent);
begin
inherited;
FClassField := THelperClass.Create;
end;
destructor TMyClass.Destroy;
begin
FClassField.Free;
end;
function TMyClass.GetSomeClass: THelperClass;
begin
ShowMessage('In TMyClass.SomeClass');
Result := FClassField;
end;
procedure TMyClass.SetSomeClass(aClass: THelperClass);
begin
ShowMessage('In TMyClass.SetSomeClass');
FClassField := aClass;
end;
{ THelperClass }
procedure THelperClass.SomePublicProc;
begin
ShowMessage('In THelperClass.SomePublicProc');
end;
end.
----------------------------------------------------------------------------
--
TMyClass is the main class which I want to convert to ActiveX using the
ActiveX Wizard in D7. As you would have noticed, I have a published property
of type THelperClass, a function which returns objects of type THelperClass,
and a procedure which takes THelperClass as argument.
My problem is that after I install this component and use the Delphi ActiveX
Wizard to create ActiveX component, I find that the above mentioned
property, method and function is not available in my ActiveX Component. The
HelperClass has not been made available or exposed in the ActiveX. How can I
do that? How can I expose class properties when converting to ActiveX? Is
there any other way of creating ActiveX other than through the Wizard in
Delphi?
Somebody please help me on this.
Thanks in advance.
--
Sam
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Thu Oct 23, 2003 12:35 pm Post subject: Re: Help with ActiveX Creation Please! |
|
|
<
I find that the above mentioned property, method and
function is not available in my ActiveX Component.
No. The whole point of ActiveX controls is that they should
be usable in other languages than Delphi - and other
languages do not understand Delphi classes. You need to
change this property into a standard automation type -
i.e., one of the types that can be stored in an OleVariant.
There are two solutions to your problem. You can add
properties to your control that allow the user to
manipulate its internal THelperClass, e.g.
property HelperClassname: string;
procedure SetHelperClassInfo(Name: string; Number:
integer);
For classes of any size that's very tedious, of course, and
the better solution is to use interfaces. Create an
IHelperClass interface, make your THelperClass implement
it, and pass IHelperClass interfaces around.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Thu Oct 23, 2003 2:51 pm Post subject: Re: Help with ActiveX Creation Please! |
|
|
Hi Deborah,
Thanks for the solutions.
| Quote: | There are two solutions to your problem. You can add
properties to your control that allow the user to
manipulate its internal THelperClass, e.g.
property HelperClassname: string;
procedure SetHelperClassInfo(Name: string; Number:
integer);
|
This doesn't look very practical because I have too many such Helper Classes
with lot of properties within it. Providing all that to the user would make
it little confusing for him.
| Quote: | For classes of any size that's very tedious, of course, and
the better solution is to use interfaces. Create an
IHelperClass interface, make your THelperClass implement
it, and pass IHelperClass interfaces around.
|
That sounds like a good solution. But does it map properly when converted to
ActiveX using the Wizard? For example, Will it be possible for the user to
say MyClass.HelperClass.Prop1 := 10; ?
I am a newbie in COM and ActiveX Technologies. Could you give an example on
how to make this work?
Thanks again.
--
Sam.
"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> wrote in
message news:VA.00001d80.001bb2c2 (AT) blueyonder (DOT) co.not-this-bit.uk...
| Quote: | Sam:
I find that the above mentioned property, method and
function is not available in my ActiveX Component.
No. The whole point of ActiveX controls is that they should
be usable in other languages than Delphi - and other
languages do not understand Delphi classes. You need to
change this property into a standard automation type -
i.e., one of the types that can be stored in an OleVariant.
There are two solutions to your problem. You can add
properties to your control that allow the user to
manipulate its internal THelperClass, e.g.
property HelperClassname: string;
procedure SetHelperClassInfo(Name: string; Number:
integer);
For classes of any size that's very tedious, of course, and
the better solution is to use interfaces. Create an
IHelperClass interface, make your THelperClass implement
it, and pass IHelperClass interfaces around.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Thu Oct 23, 2003 3:36 pm Post subject: Re: Help with ActiveX Creation Please! |
|
|
<
For example, Will it be possible for the user to
say MyClass.HelperClass.Prop1 := 10; ?
Yes.
<
I am a newbie in COM and ActiveX Technologies. Could you
give an example on how to make this work?
This is a good site to start at:
http://www.gekko-software.nl/Delphi/
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Fri Oct 24, 2003 7:31 am Post subject: Re: Help with ActiveX Creation Please! |
|
|
Thanks Deborah,
I'll go thru that.
Sam.
"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> wrote in
message news:VA.00001d83.00c1c4eb (AT) blueyonder (DOT) co.not-this-bit.uk...
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Fri Oct 24, 2003 12:50 pm Post subject: Re: Help with ActiveX Creation Please! |
|
|
Hi Deborah,
That site was of great help. I was able to expose my helper class as a COM
DLL. Now, I'm seeing how I can convert my already existing VCL Helper
Classes into a COM Class,.....or how I can use this logic to expose my huge
collection of Helper classes related to my existing VCL component and
convert it to an ActiveX Component.
Thanks Again.
--
Sam.
"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> wrote in
message news:VA.00001d83.00c1c4eb (AT) blueyonder (DOT) co.not-this-bit.uk...
|
|
| Back to top |
|
 |
Gary Wardell Guest
|
Posted: Sun Oct 26, 2003 10:34 pm Post subject: Re: Help with ActiveX Creation Please! |
|
|
Hi,
I found this site helpful too.
I will say though it's a little rough going for somebody that is new to
Delphi and the nuts and bolts of ActiveX. Even thought I've been using VB5 &
6 for years I have never had to consider the low level stuff needed for
this. His tutorial, while helpful, leaves a few gaps while going through
things with Delphi 6.
Gary
|
|
| Back to top |
|
 |
Sam Guest
|
Posted: Sat Nov 01, 2003 8:16 am Post subject: Re: Help with ActiveX Creation Please! |
|
|
Hi,
Is there any way by which I can directly convert this to ActiveX using the
Delphi Wizard? I've noticed that when using the Delphi ActiveX Wizard, the
THelperClass and other such helper classes are not converted in the Type
Library and are hence not exposed to user. After the Wizard creates the
implementation file and type library, I have to manually edit the Type
Library and add the helper class interface and other such classes. Is there
a way by which Delphi will do this automatically?
Thanks,
--
Sam.
"Sam" <anishsam (AT) gnostice (DOT) com> wrote
| Quote: | Hi Everybody,
I need some real help to crack this ActiveX problem I'm facing. Please
help
me.
Take a look at the following unit/code:
--------------------------------------------------------------------------
--
--
unit MyClassU;
interface
uses Classes, Controls, Dialogs;
Type
// Helper class for TMyClass, which acts as argument in TMyClass
methods.
THelperClass = class(TPersistent)
private
FField1: Integer;
FField2: string;
public
procedure SomePublicProc;
published
property Prop1: Integer read FField1 write FField1;
property Prop2: string read FField2 write FField2;
end;
// Main component class to be converted to ActiveX Control.
TMyClass = class(TWinControl)
private
FClassField: THelperClass;
FIntField: Integer;
public
procedure SetSomeClass(aClass: THelperClass);
function GetSomeClass: THelperClass;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property HelperProp: THelperClass read FClassField write FClassField;
property IntProp: Integer read FIntField write FIntField;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Test', [TMyClass]);
end;
{ TMyClass }
constructor TMyClass.Create(AOwner: TComponent);
begin
inherited;
FClassField := THelperClass.Create;
end;
destructor TMyClass.Destroy;
begin
FClassField.Free;
end;
function TMyClass.GetSomeClass: THelperClass;
begin
ShowMessage('In TMyClass.SomeClass');
Result := FClassField;
end;
procedure TMyClass.SetSomeClass(aClass: THelperClass);
begin
ShowMessage('In TMyClass.SetSomeClass');
FClassField := aClass;
end;
{ THelperClass }
procedure THelperClass.SomePublicProc;
begin
ShowMessage('In THelperClass.SomePublicProc');
end;
end.
--------------------------------------------------------------------------
--
--
TMyClass is the main class which I want to convert to ActiveX using the
ActiveX Wizard in D7. As you would have noticed, I have a published
property
of type THelperClass, a function which returns objects of type
THelperClass,
and a procedure which takes THelperClass as argument.
My problem is that after I install this component and use the Delphi
ActiveX
Wizard to create ActiveX component, I find that the above mentioned
property, method and function is not available in my ActiveX Component.
The
HelperClass has not been made available or exposed in the ActiveX. How can
I
do that? How can I expose class properties when converting to ActiveX? Is
there any other way of creating ActiveX other than through the Wizard in
Delphi?
Somebody please help me on this.
Thanks in advance.
--
Sam
|
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Sat Nov 01, 2003 10:13 am Post subject: Re: Help with ActiveX Creation Please! |
|
|
<
Is there a way by which Delphi will do this automatically?
No, I'm afraid you have to do it by hand.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
| 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
|
|