Re: Help - What is this code used for ?
- From: "Bruce Roberts" <dontsendtober@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 28 Nov 2005 12:56:14 -0500
"Eddy Fontaine" <someone@xxxxxxxxxxxx> wrote in message
news:438b3d2d$0$10963$ba620e4c@xxxxxxxxxxxxxxxxx
>I found this code in the INDY 9 basic TCPClient demo, and i have no idea
> what it is used for...
> procedure TfrmMain.LockControls(ALock: Boolean);
> var
> i : integer;
> begin
> for i := 0 to componentcount-1 do
> if TControl(Components[i]).Tag = 99 then
> TControl(Components[i]).Enabled := ALock;
> end;
The code has a bug, at least IMO. tForm.Components has an entry type of
tComponent, not tControl. It is possible to have a non tControl component
on a form. The reason that the code doesn't fail is that Tag is declared in
tComponent and I presume that the author has only set the Tag of components
of type tControl to 99. However the code would have been tighter if it were
written
if Components [i].Tag = 99
then begin
Assert (Components [i] is tControl);
tControl (Components [i]).Enabled := aLock;
end;
or
if (Components [i].Tag = 99) and (Components [i] is tControl)
then tControl (Components [i]).Enabled := aLock;
By the looks of things the code is used to enable / disable a group of
controls on the main form.
.
- Follow-Ups:
- Re: Help - What is this code used for ?
- From: Eddy Fontaine
- Re: Help - What is this code used for ?
- References:
- Help - What is this code used for ?
- From: Eddy Fontaine
- Help - What is this code used for ?
- Prev by Date: Re: Help ! What is this code needed for ?
- Next by Date: Re: Help - What is this code used for ?
- Previous by thread: Help - What is this code used for ?
- Next by thread: Re: Help - What is this code used for ?
- Index(es):
Relevant Pages
|
|