Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Form constructor overload

512 views
Skip to first unread message

Ariel Mendelzon

unread,
Feb 11, 2001, 1:30:15 PM2/11/01
to
Hi everyone!!!
I have a little problem: I need to create a form sending it extra parameters
and I don't know how to...... I can't overload the constructor or create a
new one because delphi raises an error...
does anyone know how to do this??
thank you so much

-Ariel Mendelzon


Glynn Owen

unread,
Feb 11, 2001, 1:55:26 PM2/11/01
to
Just give your constructor a name that is different from CREATE, and
then be sure to call the Create constructor before you do anything else.

HTH, Glynn

Ross Hemingway

unread,
Feb 11, 2001, 5:23:35 PM2/11/01
to
unit Unit2;

interface
uses Forms, Classes;

type
TFormExtra = class(TForm)
private
FExtra: Integer;
public
constructor Create(AOwner: TComponent; Extra: Integer); reintroduce;
end;


implementation

{ TFormExtra }
constructor TFormExtra.Create(AOwner: TComponent; Extra: Integer);
begin
FExtra := Extra;
inherited Create(AOwner);
end;

end.

--
Ross Hemingway

Carl Reynolds

unread,
Feb 11, 2001, 6:53:12 PM2/11/01
to
"Ariel Mendelzon" <pon...@sinectis.com.ar> wrote in message
news:966ln9$sr...@bornews.inprise.com...

> I have a little problem: I need to create a form sending it extra
parameters
> and I don't know how to...... I can't overload the constructor or
create a
> new one because delphi raises an error...

Redeclare the constructor and use "reintroduce" to avoid the compiler
warning. Remember to call the inherited constructor, eg.

procedure TMyForm.Create(MyOwner: TComponent; MyParam: TMyParam);
begin
inherited Create(MyOwner);
...
end;

Cheers,
Carl


Ross Hemingway

unread,
Feb 11, 2001, 5:53:08 PM2/11/01
to
unit Unit2;

interface
uses Forms, Classes;

type
TFormExtra = class(TForm)
private
FExtra: Integer;
public
constructor Create(AOwner: TComponent; Extra: Integer); reintroduce;
end;


implementation

{ TFormExtra }
constructor TFormExtra.Create(AOwner: TComponent; Extra: Integer);
begin

inherited Create(AOwner);
FExtra := Extra;
end;

end.

--
Ross Hemingway

Peter Speden

unread,
Feb 11, 2001, 10:34:09 PM2/11/01
to

"Ariel Mendelzon" <pon...@sinectis.com.ar> wrote in message
news:966ln9$sr...@bornews.inprise.com...
type TMyForm = class (TForm)
private
FMyValue : string;
Public
constructor Create (AOwner : TComponent; AMyValue : string); reintroduce;
property MyValue : string read FMyValue;
end;

constructor TMyForm.Create (AOwner : TComponent; AMyValue : string);
begin
inherited Create (AOwner);
FMyValue := AMyValue;
end;

HTH

Ralph Friedman (TeamB)

unread,
Feb 12, 2001, 6:09:42 AM2/12/01
to
Ariel,

in article <966ln9$sr...@bornews.inprise.com>, you wrote:

> I have a little problem: I need to create a form sending it extra parameters
> and I don't know how to...... I can't overload the constructor or create a
> new one because delphi raises an error...
> does anyone know how to do this??
> thank you so much
>

type
TForm2 = class(TForm)
<deletia>
private
{ Private declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent; ACaption: string); reintroduce;
overload;
end;

var
Form2: TForm2;

implementation

{$R *.DFM}

constructor TForm2.Create(AOwner: TComponent; ACaption: string);
begin
inherited Create(AOwner);

Caption := ACaption;
end;

--
Regards
Ralph (TeamB)
===

0 new messages