Title: Scalling controls according to choosed font
Question: Probably you want that your form could be scalled according to some parameters, like for example, if you have an option in your application that gives the user a chance to change application font, you need that your application could scale correctly.
Answer:
To do this you must use a function ScaleBy (in fact a very usefull function, and
you'll find more articles here at D3k about this function) to resize your form
correctly.
procedure TForm1.Button3Click(Sender: TObject);
begin
FontDialog1.Font := Font;
if FontDialog1.Execute then
begin
// ScaleBy doesn't resize the form, just children controls. So, we must resize
// the form.
SetBounds(Left, Top, Muldiv(Width, Abs(FontDialog1.Font.Height), Abs(Font.Height)),
Muldiv(Height, Abs(FontDialog1.Font.Height), Abs(Font.Height)));
// Resize accordin to the new values.
ScaleBy(Abs(FontDialog1.Font.Height), Abs(Font.Height));
// Assign the choosen font to the form
Font := FontDialog1.Font;
end;
end;