Re: Newbie question about release, freeAndNil, etc
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 26 Aug 2005 05:15:21 -0700
I usually use a "with ...", without specifying a reference variable
when I "ShowModal". I know all the excoriation of "with" and accept the
slight risks within the small amount of calling code.
Here's a typical call for a modal form which has to be placed in
association with an icon.
with TTalkFSHelpForm.Create(nil) do begin
{position to right of footswitch icon & with bottoms aligned}
PosnPt := point(FootSwImg.Left + FootSwImg.Width,
FootSwImg.Top + FootSwImg.Height - Height);
PosnPt := Self.ClientToScreen(PosnPt);
{set display position}
Left := PosnPt.X;
Top := PosnPt.Y;
ShowModal;
Free;
end;
TForm.Release is basically required where a form would be freed from
one of its own methods, and normally when that method returned it would
find no form because it had been freed. Release delays the freeing of
the form until all its methods have returned.
TCollection / TCollectionItem (if that is what you mean by
"TCollection") is not, in my experience used with forms. Although there
is no reason why it should not be It is a very useful relationship
where the "glue and skeleton" connecting the collection and its items
is provided by TCollection and TCollectionItem, and where private cross
references between the collection class and the item class are
necessary in code for their proper working. There are some useful
typecasting tips to know if you are using them, but I have found them
very useful.
Alan Lloyd
.
- References:
- Newbie question about release, freeAndNil, etc
- From: swansnow
- Re: Newbie question about release, freeAndNil, etc
- From: Maarten Wiltink
- Re: Newbie question about release, freeAndNil, etc
- From: e.p
- Newbie question about release, freeAndNil, etc
- Prev by Date: Re: Newbie question about release, freeAndNil, etc
- Next by Date: Re: terminal services compatibility
- Previous by thread: Re: Newbie question about release, freeAndNil, etc
- Next by thread: Re: Newbie question about release, freeAndNil, etc
- Index(es):