>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

Reply via email to