When working with Delphi version 4 (or above) several properties are designed to help us maintain the look and layout of controls on a form.
Use Align to align a control to the top, bottom, left, or right of a form or panel and have it remain there even if the size of the form, panel, or component that contains the control changes. When the parent is resized, an aligned control also resizes so that it continues to span the top, bottom, left, or right edge of the parent.
Use Constraints to specify the minimum and maximum width and height of the control. When Constraints contains maximum or minimum values, the control cant be resized to violate those constraints.
Use Anchors to ensure that a control maintains its current position relative to an edge of its parent, even if the parent is resized. When its parent is resized, the control holds its position relative to the edges to which it is anchored. If a control is anchored to opposite edges of its parent, the control stretches when its parent is resized.
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure ScaleForm
(F: TForm; ScreenWidth, ScreenHeight: LongInt) ;
begin
F.Scaled := True;
F.AutoScroll := False;
F.Position := poScreenCenter;
F.Font.Name := 'Arial';
if (Screen.Width <> ScreenWidth) then begin
F.Height :=
LongInt(F.Height) * LongInt(Screen.Height)
div ScreenHeight;
F.Width :=
LongInt(F.Width) * LongInt(Screen.Width)
div ScreenWidth;
F.ScaleBy(Screen.Width,ScreenWidth) ;
end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
VCL
And finally, why bother with coding when there are components for all your resizing problems (try them and choose the best one for you):
Need forms that keep proportionality when being resized manually? And also when being Maximized or Tiled/Cascaded? Forms for both MDI and SDI type applications? TNFormSizing is all you need for that. Just put the TNFormSizing on your form and choose an option for ProportionType - its only published property. Free with code.
To use this free component (+ source code), just drop it onto a form and then add one line of code apiece to the form's OnCreate and OnResize handlers (optionally resizes the fonts of the components).
Another free component. Includes component editor with all controls for this container in table format. Then you can define the behavior for each control. All settings will be stored in DFM file automatically.
Shareware component: resizes at design time, automatic resolution independence, supports third party/custom controls, supports all border styles, etc.
All you do is drop PerfectSize on a form and the rest is handled for you! At run time, your controls and fonts are always kept in proper scale and proportion regardless of the user's screen resolution. Shareware.

