Screen resolution is no issue, unless you are talking about maximized forms, so I will assume that. That implies you having trouble with aligning components in the center of changing form sizes.
Considering a single control in that regard, then the solution is relatively easy: change its position in an OnResize
event handler:
procedure TForm1.FormResize(Sender: TObject);
begin
Control.Left := (ClientWidth - Control.Width) div 2;
Control.Top := (ClientHeight - Control.Height) div 2;
end;
For a multiple control situation, the most easy solution is to place them on a single container, e.g. a panel, and use the above approach. But for small forms, this could result in the container being too large resulting in showing the form's scroll bars as you say (which can be suppressed by the AutoScroll
property of the form), and for large form sizes, the container could render too small.
Another solution is the relative anchor solution: Just set the Anchors
property to []
for all controls, and all controls will stay in their relative position, regardless form size. (This trick also applies to solution #1).
In both cases, the control's size and font size remain the same which could or will distort the layout. There are multiple possible solutions for that, but that's beyond the scope of your question and this answer I think.