Question - is the new component automatically freed when the form is
destroyed?
I've normally kept a list of components created on the fly and specifically
freed them - maybe I don't need to.
Stephen
-----Original Message-----
From: Stacey Verner [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 29 November 2000 16:02
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Creating A Class
You need to set the parent to a form, tabsheet, panel etc..
e.g.
procedure TForm1.Button1Click(Sender: TObject);
var
MyList1, Q: PMyList;
begin
New(Q);
MyList1 := Q;
MyList.Parent := Self;
MyList1.Visible := True;
end;
On another note. The way you are createing you objects looks a little odd to
me. I checked the help to see what you were doing and its all fine, but the
way we would normally do it is as follows:
procedure TForm1.Button1Click(Sender: TObject);
var
MyList1: TMyList;
begin
MyList1 := TMyList1.Create(nil {or whatever paremeters are requitred});
MyList.Parent := Self;
MyList1.Visible := True;
end;
Stacey
> -----Original Message-----
> From: Chrissy R [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 29 November 2000 3:51 p.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: Creating A Class
>
>
> Hi,
>
> I am trying to create, at run time, a number of instances of
> a TTreeView. I have
> created a class of this type and I will add some methods to
> this. I can create this
> in one unit and, when I press a button on my form, things
> seem to work but I
> cannot get this new object to display. The code that I have
> for the button click is
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
> MyList1, Q: PMyList;
> begin
> New(Q);
> MyList1 := Q;
> MyList1.Visible := True;
> end;
>
> The MyList1.Visible line fails with an access violation and I
> do not know what
> I am doing. Please help me.
>
> Chrissy.
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"