Solved

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

Posted on 2007-03-21
2
1,336 Views
Last Modified: 2011-04-14
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;
0
Comment
Question by:QurbanDurrani
2 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 18768298
change to
       TFooClass(Contr.Controls[i]).Font.Name := 'Arial';
       TFooClass(Contr.Controls[i]).Font.Size := MulDiv(DesiredSize,96,PixelsPerInch);
0
 

Author Comment

by:QurbanDurrani
ID: 18768527
That works. Thanks you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question