Ok, that works, although I now do :-
if Frame is TWinControl then with Frame do for I := 0 to ControlCount-1 do
Controls[I].enabled:=false;
and it works too.
It was just an idea I had for a control.....Thanks
Jeremy Coulter
-----Original Message-----
From: Aaron Scott-Boddendijk [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 11, 1999 09:13
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Detecting Componets
>Just wondering, how do the following :-
>I have a Frame componet on a form, and then I have some components on that
frame.
>How do i detect what components are on it ? and then do something, like
>change the font colour or something equally simple.....????
procedure TForm1.FormCreate(Sender: TObject);
var
I :Integer;
begin
if Frame is TWinControl then with Frame do for I := 0 to ControlCount-1 do
begin
if Controls[I] is TButton then Tbutton(Controls[I]).Caption := 'Button
(Control '+IntToStr(I)+')';
if Controls[I] is TCustomMemo then TCustomMemo(Controls[I]).Lines.Text
:= 'Memo (Control '+IntToStr(I)+')';
end;
end;
The IS command can be used to check if an instance is a certain class (or
descendant of that class). The 'Controls'
and 'ControlCount' properties are those controls which are on the
TwinControl (Frame). The components property
lists those controls owned by the Frame not necessarily those displayed on
the frame. See the 'Owner' and 'Parent'
property definitions of TComponent and TControl respectively.
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz