The VCL form designer offers pink guidelines for aligning controls at their respective text base lines:
But as far as I can tell this doesn't work for labels and checkboxes. Update: It works for labels if you place the controls exactly, e.g. by Ctrl-arrow. It kind of works for checkboxes - see screenshot.
Now, on some forms I'm creating controls in code, e.g.
ed := TEdit.Create(Self);
ed.SetBounds(...);
ed.Parent := SomePanel;
etc. How can I ensure that their text base lines are aligned? I'd like to have this for edits, comboboxes, labels and checkboxes. The result should look like this (without the red line, of course :-)):
Edit: My current approach is to call something like AlignTop(8, [Edit1, ComboBox1], [CheckBox1, Label1]);
with
procedure ControlArray_SetTop(const AControls: array of TControl; ATop: Integer);
var
i: Integer;
begin
for i := Low(AControls) to High(AControls) do
AControls[i].Top := ATop;
end;
procedure AlignTop(ATop: Integer; const AControls: array of TControl; const ALabelLikeControls: array of TControl);
begin
ControlArray_SetTop(AControls, ATop);
ControlArray_SetTop(ALabelLikeControls, ATop + 3);
end;
My goal is to replace it with something more robust and less hacky.