Solved

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

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process Javascript errors with Delphi TWebBrowser 1 136
Printing problem 2 95
Delphi 2 60
CheckListBox usage 3 59
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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