Author: Tomas Rutkauskas
How to resize controls according to the users font settings
Answer:
You don't need the resolution (unless you plan on rearranging the controls on your
form depending on resolution). You can get the appropriate "base unit" for sizing
controls like this:
1 2 BaseUnit := Canvas.TextHeight('0');
This returns a value which is 8 times what Windows calls a "dialog unit." Every
control can be sized to some integral number of dialog units. For example, I
normally make my buttons 40 units wide and 14 units tall. So the code would go
something like this:
3 ButtonWidth := (40 * BaseUnit) div 8;
4 ButtonHeight := (14 * BaseUnit) div 8;
5 MyButton.SetBounds(L, T, ButtonWidth, ButtonHeight);
This will resize the button in accordance with whatever the user's font size setting happens to be. It is the font.height that changes during the automatic scaling of the form (if you leave form.scaled set to true) and this will make the component scale as well.