relativeHeight
Type: Boolean
Availability: Read or write at any time
The relativeHeight property of the Control class specifies whether the height of a control is relative to the height of its parent. If this property is set to true, the control height is adjusted proportionally when the parent is resized. For example, this means that list boxes can be sized according to the form height.
The settings of the relativeHeight property are listed in the following table.
Value | Description |
---|---|
false | If the parent is resized, no action occurs (the default) |
true | Resize the control height in proportion to the size change undergone by the parent |
Setting the relativeHeight property to true causes the adjustment of the height for the control when the parent size changes. For example, if all of the relative properties are set to true, two adjacent list boxes resize, move, and are still adjacent after the resize of a form. Similarly, if you set the relativeTop and relativeLeft properties to true, a button remains the same size but it is positioned proportionally to the form size.
Some controls automatically resize themselves, and setting this property may have no effect. In addition, the relativeHeight property is ignored when a control is aligned. (See also the parentAspect property.)
The size ratios between the control and its parent are calculated when:
-
A form is loaded, if any of the property values are set to true.
The ratios are calculated using the development property values of left, top, height, and width of the control and its parent established by the Painter in the JADE development environment.
-
The form is running:
-
If any of the relativeLeft, relativeTop, relativeHeight, or relativeWidth properties of the control are changed to true.
-
If any of the left, top, height, or width properties of the control are set and any of the relative properties are set to true.
-
If the move method of the Window class is called for the control and any of the relative properties are set to true.
In these situations, the current size of the control and parent recalculate the size ratios.
-
If logic changes the position or size of the control, the distances to the edges of the parent of the control are re-evaluated and used from then on (that is, the relative ratios are re-evaluated).
When using the relativeHeight property, some controls have fixed heights. Any stretching is ignored for those cases, as follows.
-
A Button control that is automatically sized to its picture property
-
Any fixed height CheckBox control
-
Any fixed height ComboBox control
-
A Label control that is automatically sized
-
Any fixed height OptionButton control
-
A Picture control that automatically sizes to its picture property; that is, Stretch_ControlTo (2) and Stretch_Proportional (3)
-
An automatically positioned Sheet control
The following example shows the use of the relativeHeight property.
setFormProperties(pScaleForm, pRelativeSize: Boolean) updating; vars count : Integer; begin // Set the form's scale property. self.scaleForm := pScaleForm; // Now set the relative size and position properties of the // form's controls. foreach count in 1 to self.controlCount do self.controls(count).relativeHeight := pRelativeSize; self.controls(count).relativeLeft := pRelativeSize; self.controls(count).relativeTop := pRelativeSize; self.controls(count).relativeWidth := pRelativeSize; endforeach; end;