Anchoring GUI components in FireMonkey
Asked Answered
O

5

8

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.

Orientalism answered 2/9, 2011 at 15:22 Comment(4)
There is FMX.Types.TControl.Anchors, but it's private and so not available.Perplexed
You might want to look at the TLayout component. Looks like you drop it on the form, configure it and then drop some components into it... just a guess though.Erlina
@Bob: alignment is not the same as anchoring.Orientalism
@Gregor: exactly. Anchoring makes a lot of sense for most uses. That one can do animation etc. is fine, but one doesn't always need or want that. Anchors would be nice.Benzine
F
11

To anchor a control is straight and requires reading the documentation.

Factoring answered 2/9, 2011 at 17:24 Comment(2)
I would love to see the image, but it's too small, can you post a bigger version?Extremism
I wondered if it was too small. I just dropped in a larger version.Factoring
E
8

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

Erlina answered 2/9, 2011 at 16:37 Comment(6)
That for component alignment, not component anchoring. For instance if I need am OK button to stay the same size but follow lower right window resizing. Alignment does not do that.Orientalism
@Gregor Maybe I just don't understand... If I drop a TLayout on the Form and set it's Alignment to alBottom the drop a TButton onto the TLayout and set it's alignment to alRight it follows the form's resizing nicely.Erlina
that appears to work but makes GUI design a pain. Simple anchoring is no longer available, now I have to create TLAyouts. This is like the old days with TPanels to get things to stay where you want them. Welcome to 1990Orientalism
@Gregor- Simple anchoring probably won't play well with the scaling, animation and 3D features of this new FireMonkey frameworks...Erlina
@Bob A: why not? It is clear that some of the effects should not be combined, so anchoring should not be combined with motion animation. That's common sense, IMO.Benzine
@Rudy - Just an uneducated guess on my part... I've only had a chance to play with FireMonkey for about 4 hours this afternoon. I'll tell you this, I am blown away by the potiental of it. I think everyone involved has done an impressive job with this release of Delphi. :)Erlina
J
5

Here's the answer you are looking for: FMX controls do not have anchors.

I imagine this will be a "next version" feature.

Joella answered 2/9, 2011 at 15:34 Comment(4)
That kind-of makes Firemonkey useless. No I'll reword that, it makes Firemonkey useless.Orientalism
((: they're in the -- what I like to call -- "monkey business -- firemonkey"Eardrum
This is not true, use Margins and Padding, its explained in the wiki docs. No as immediately obvious as anchors but they work. See my answer below.Factoring
Correct, not useless, just harderOrientalism
E
1

A quick look at the align property reveals many more choices than we had in previous Delphi versions:

enter image description here

Doesn't that solve your problem (at least partially).
I remember getting by OK for a long time just using nested panels and align to layout stuff.

Extremism answered 2/9, 2011 at 17:17 Comment(3)
isn't that a huge step backwards. I have to nest TLayouts to get anchoring. If I recall from my Builder 5 days, that was a huge pain in the *ssOrientalism
It is, but at least that does not make Firemonkey useless, it just means there's room for improvement. Everybody was screaming to release all those promised features already. It's even in the files (see http://docwiki.embarcadero.com/VCL/XE2/en/FMX.Types.TControl.Anchors, however I guess they haven't ironed out all the bugs yet, so they've made those Anchors private. In time all will be right. I for one am tickled pink with the chance to write for iOS (where there is no resizing :-).Extremism
"isn't that a huge step backwards"...oh common - just continue to use VCL if you're not ready for something new. There are so much great things in Firemonkey and this is the first release of it...of course there are still some issues...far away from being useless IMHOLemonade
D
0

You can use LiveBindings and expressions to set the properties of your control based on the parent control, though it's a lot of work.

Otherwise, use Margins and Padding (like HTML/CSS).

Dialecticism answered 3/10, 2011 at 22:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.