Forum > Designer

Aligning two buttons (etc.) relative to the middle of a form

(1/2) > >>

MarkMLl:
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:
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:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
Thanks, I'll check that.

MarkMLl

wp:

--- Quote from: howardpc on September 20, 2021, 11:37:37 am ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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.

--- End quote ---
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.

Navigation

[0] Message Index

[#] Next page

Go to full version