Solved

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

Posted on 2007-03-21
2
1,323 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 161
Splash screen too shortlived 11 113
PDF library for Delphi 2 89
Sending Gmail through Delphi 3 69
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now