Link to home
Start Free TrialLog in
Avatar of QurbanDurrani
QurbanDurrani

asked on

'List Index out of bound(6)' with iterating through the components on a form.

The following code throws a 'List Index Out of bounds(6)'  error. I am trying to change font for all the components on a form and any components within a component.(for example a form containing a pagecontrol which contains several tabsheets, which inturn contain several different components.)
What am I doing wrong?

procedure TSLCCOTForm.FormShow(Sender: TObject);
begin
  if PixelsPerInch <> 96 then
  Iterate(SLCCOTForm);
end;

procedure TSLCCOTForm.Iterate(Contr: TWinControl);
var
i, DesiredSize : integer;
begin
  for i := 0 to Contr.ControlCount -1 do
    begin
       DesiredSize := 8;
       TFooClass(Controls[i]).Font.Name := 'Arial';
       TFooClass(Controls[i]).Font.Size := MulDiv(DesiredSize,96,PixelsPerInch);
       if Contr.Controls[i] is TWinControl then
       Iterate(Contr.Controls[i] as TWinControl);
    end;
end;
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QurbanDurrani
QurbanDurrani

ASKER

That works. Thanks you.