Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anchoring GUI components in FireMonkey

Just started testing FireMonkey and can't find a way to make dynamically sized/positioned components.

VCL had the Anchor property, FM does not.

Anybody see something I missed

Update:

Simple anchoring is not available in FM. You have to create TLayouts and align those, then put the controls inside the panel to have them 'stick'. If you used older version of Builder or Delphi, this will be the same as we used to have to do with TPanels.

like image 919
Gregor Brandt Avatar asked Sep 02 '11 15:09

Gregor Brandt


2 Answers

This is the answer to your question. The anchors property in VCL has apparently been replaced by Margins and Padding (due to performance considerations) and I found some documentation at the XE2 wiki (http://docwiki.embarcadero.com/RADStudio/en/FireMonkey_Application_Design). I doubt if anchors will be put in at a later date. To anchor two buttons (Ok and Cancel) at the bottom of a form on the right side do the following.See images below for the Ok and cancel button.

enter image description here

Place a small panel aligned to the bottom on the form, say about 40 height. Set the 'Margins' on the bottom panel to create a smaller space in which the buttons will live, make sure you set the align the button to alRight. For example the gap between the right edge of the form and the right most button has a margin of 15. The top and bottom margins were set to 12. That anchors the right most button.

'Padding' is the opposite to a margin, the padding puts space outside the control. To the right most button I added a padding of 20 to the left side, this will be the space between the two buttons. For the second button to the left of the first all we need to do is set the align property to alRight, no need to adjust the padding or margins.

like image 142
rhody Avatar answered Oct 16 '22 05:10

rhody


Drop multiple TLayout components on the form and configure their alignment properties as desired. Drop other components into these layouts and set their alignment properties relative to the TLayout they are contained in. Seems to be working for me...

like image 8
Bob A Avatar answered Oct 16 '22 06:10

Bob A