Unit 'Controls' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#lcl]


The set of anchor definitions for this control.


Source position: controls.pp line 1720

public property TControl.Anchors : TAnchors
  read FAnchors
  write SetAnchors
  stored IsAnchorsStored
  default [akLeft, akTop];


Anchors is a TAnchors property which contains the edges used to align the position of the control relative to its Parent. Anchors allow the control to be repositioned and/or resized when the parent control is resized. Coordinate values in the control - like Left, Top, Bottom, and Right properties - are updated when the corresponding edge is anchored to its Parent.

The default value for the property is [akLeft, akTop], and indicates that only the Top and Left coordinates are anchored in the parent control.

For example:

[akLeft, akRight]
Causes the relative width for the control to be adjusted when the width of the parent control is changed.
[akTop, akBottom]
Causes the relative height for the control to be adjusted when the height of the parent control is changed.
[akTop, akLeft, akRight]
Causes the relative width (but not the height) for the control to be adjusted when the parent is resized. Like using the Align property.
[akTop, akLeft, akBottom, akRight]
Causes both the height and width to be adjusted when the parent control is resized. Like using alCustom in Align.

Setting a new value for the property causes the UpdateAnchorRules and AdjustSize methods to be called.

Values in Anchors are used (along with Align) in the DoAutoAdjustLayout method. They control whether values in Left, Top, Bottom, and Right are calculated using the ClientWidth and ClientHeight for the Parent control. The values in Anchors also used in the HeightIsAnchored and WidthIsAnchored methods.

Values in Anchors may be updated when a new value is assigned to the Align property which conflicts with the existing values in the property. They may also be updated when values are assigned to AnchorSide which cause vertical or horizontal centering to a sibling control (AnchorVerticalCenterTo, AnchorHorizontalCenterTo) or alignment to a companion control (AnchorToCompanion).

See also



Set type used to store values from the TAnchorKind enumeration.



The control side to be anchored.



Specifies the placement of the control on its Parent control.



Array of anchor definitions, indexed by the control sides.



Smart way to DoAutoSize.



Applies layout changes using the specified policy and scaling proportions to the control.



The height for the client area on the control.



The width of the client area for the control.



The control within which the control is shown.

CT Web help

CodeTyphon Studio