Aligning two buttons (etc.) relative to the middle of a form lazarus / 10-Designer ---------------------------------------------------------------------- MarkMLl · 2021-08-28 07:04 When a form has "Cancel" and "OK" buttons, it's easy enough to align them to the bottom using the anchor editor. How does one align them horizontally, particularly if the form can be resized? Is there some datum running up the middle of the form to which the anchor editor can refer, or is the best way to put e.g. a zero-width bevel in the middle of the form as a dummy control relative to which others can be anchored? MarkMLl ---------------------------------------------------------------------- MarkMLl · 2021-09-20 08:44 I ended up using a zero-width bevel running up the middle of the form as a construction line. Not sure whether there's a better way using some combination of anchors etc. MarkMLl ---------------------------------------------------------------------- howardpc · 2021-09-20 09:37 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i okButton.AnchorsideLeft.Control := theForm;okButton.AnchorsideLeft.Side := asrCenter;okButton.BorderSpacing.Left{or .Right as needed} := distanceFromCenter;ought to do it. You could also use the AnchorsideRight property, of course, but by default a control's Anchors already includes akLeft. ---------------------------------------------------------------------- MarkMLl · 2021-09-20 10:05 Thanks, I'll check that. MarkMLl ---------------------------------------------------------------------- wp · 2021-09-20 11:10 Quote from: howardpc on September 20, 2021, 11:37:37 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i okButton.AnchorsideLeft.Control := theForm;okButton.AnchorsideLeft.Side := asrCenter;okButton.BorderSpacing.Left{or .Right as needed} := distanceFromCenter;ought to do it. You could also use the AnchorsideRight property, of course, but by default a control's Anchors already includes akLeft. In my experience this is not working. "Centered is centered" and there is no way to move the centered control, neither with the left nor with the right BorderSpacing, I always follow the ideas already proposed by MarkMLI: add a TBevel to the container, set its Shape to bsSpacer to make it invisible and set its width to the distance that the two buttons on each side should have. Anchor the right side of the left button to the left side of the bevel, and anchor the left side of the right button to the right side of the bevel. ---------------------------------------------------------------------- howardpc · 2021-09-20 12:29 Yes, wp, you are quite correct. I should have tried out my thought in practice before suggesting something that does not work. ---------------------------------------------------------------------- MarkMLl · 2021-09-20 12:43 And I should have checked before agreeing with you :-) Actually, I think that the IDE actively warns that border control is inoperative with certain combinations. MarkMLl ---------------------------------------------------------------------- Leledumbo · 2021-09-21 05:25 Not sure if the attached project is what you expected, but basically just play around with ChildSizing. ---------------------------------------------------------------------- MarkMLl · 2021-09-21 16:49 Quote from: Leledumbo on September 21, 2021, 07:25:22 amNot sure if the attached project is what you expected, but basically just play around with ChildSizing. OK, I think I see what you've done... ChildSizing on the form/panel/groupbox etc. which then tells the children where to stand, rather than giving each child an anchor. I note that this is described at https://wiki.lazarus.freepascal.org/Autosize_/_Layout#Precedence_ru les, which has been on my screen pending time to read it for the last couple of days. I note the discussion at https://wiki.lazarus.freepascal.org/LCL_AutoSizing, which makes it sound pleasantly deterministic. In the past people have looked at things like https://constraints.cs.washington.edu/deltablue/ for UI layout, but the always appeared to come with health warnings. MarkMLl