Joined: 22 Feb 2003
|Posted: Thu Mar 13, 2003 3:01 pm Post subject: KiXforms Version 2.3.0 Beta 1 Features
|This is the first of a series of topics that will document all of the new features in the latest beta release of Kixforms. For general discussion and questions, please post to the Beta discussion thread in the Discussion forum.
Gets or sets which edges of the control are anchored to the edges of its container.
object.Anchor = [ integer ]
A bitwise combination of the following values:
0 - None. The control is not anchored to any edges of its container.
1 - Left. The control is anchored to the left edge of its container.
2 - Top. The control is anchored to the top edge of its container.
4 - Right. The control is anchored to the right edge of its container.
8 - Bottom. The control is anchored to the bottom edge of its container.
The default is Left and Top.
A control can be anchored to one or more edges of its parent container. Anchoring a control to its parent ensures that the anchored edges remain in the same position relative to the edges of the parent container when the parent container is resized. For example, if you have a Form with a Button whose Anchor property value is set to Top and Bottom, the Button is stretched to maintain the anchored distance to the top and bottom edges of the Form as the Height of the Form is increased.
The following example creates a form that contains a editable area (implemented as a TextBox) and an Exit button (implemented as a ToolButton). The desired effect is that as the form is resized, the TextBox should stretch in all four directions to maintain its size relative to the form. The Exit button should just simply "stick" to the inside top right edge of the form, moving as the form is resized.
For the TextBox to stretch in all four directions, the Anchor property should have all the bitwise anchor settings enabled, example 1+2+4+8 for a value of 15 (all sides). The ToolButton should only be attached to the top and right of the form, so that would imply a setting of 2+4 (top and right) for a value of 6.
$Form = CreateObject("Kixtart.Form")
$Form.ClientSize = 400,300
$Form.BorderStyle = 2 ; Resizable border
$TextBox = $Form.TextBox
$TextBox.MultiLine = 1
$TextBox.Location = 10,10
$TextBox.Right = $Form.ClientWidth - 100
$TextBox.Bottom = $Form.ClientHeight - 10
$TextBox.Anchor = 1+2+4+8 ; all sides
$Button = $Form.ToolButton
$Button.Top = 10
$Button.Left = $TextBox.Right + 10
$Button.Text = "Exit"
$Button.Icon = 9
$Button.OnClick = "Quit()"
$Button.Anchor = 2+4 ; just top and right