Iterating through controls within a control. Is there a way to make one call for all forms?
Posted on 2007-03-21
I have the following two procedures to change the fonts if DPI setting is not 96. As it is I would need to call the procedure in the formshow event of every form for it to take effect for every form. Is there a way to make the call to the procedure in one place where it will be executed for all forms if the DPI setting is not 96.
procedure TSLCCOTForm.FormShow(Sender: TObject);
if PixelsPerInch <> 96 then
procedure TMainForm.Iterate(Contr: TWinControl);
i, DesiredSize : integer;
for i := 0 to Contr.ControlCount -1 do
DesiredSize := 10;
TFooClass(Contr.Controls[i]).Font.Name := 'Arial';
TFooClass(Contr.Controls[i]).Font.Size := MulDiv(DesiredSize,96,PixelsPerInch);
if Contr.Controls[i] is TWinControl then
Iterate(Contr.Controls[i] as TWinControl);