Aligning and Anchoring


Controls have two remarkable properties that enable us to create professional-looking, high-quality user interfaces that can be resized without losing their usefulness or ease of use.

The Align property enables us to align a control within its parent control. When you align a control to one of the sides of the parent control, the control is automatically resized when the parent's size changes. If the Align property is set to alNone, the control will not be moved or resized when the size of the parent changes.

The Align property is usually good for container controls that have to stretch from one side of the parent control to the other. But some controls, like TButton, TCheckBox, and the like, don't have the Align property. To align these controls, you have to use the Anchors property.

The Anchors property is a set of four values that define how the control holds on to the parent. The default value of the Anchors property is [akLeft, akTop]. Controls with this Anchors value don't change their position or size at run time. For instance, the Anchors property can be used if you need a button that always holds onto the right side of the form. To force the button to remain on the right side of the form even when the form is resized, set the Anchors property of the button to [akTop, akRight] (see Figure 11-25). To change the values in a set property, click the plus sign to the left of the property to expand it, and then modify the contents of the set.

image from book
Figure 11-25: The Anchors property



Inside Delphi 2006
Inside Delphi 2006 (Wordware Delphi Developers Library)
ISBN: 1598220039
EAN: 2147483647
Year: 2004
Pages: 212
Authors: Ivan Hladni

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net