Align, Orientation Property

Purpose

Returns or sets a value that determines whether an object is displayed in any size anywhere on a form or whether it's displayed at the top, bottom, left, or right of the form and is automatically sized to fit the form's width.

Syntax

object.Align [= number]

object2.Orientation [= number]

object:Toolbar, StatusBar, Scroll, Slider, ProgressBar, Form Ocx Object
object2:Scroll, Slider, ProgressBar
number:iexp

Description

Use the Align property to position an Ocx control or Ocx Form at the border of its parent. The Orientation property sets a value (basHorizO or basVertO) that determines whether the control is oriented horizontally or vertically. The Align property always overrules the Orientation property, as well as reseting any changes previously made to Width or Height.

An Ocx Form can be used in a MDI parent (ParentW), which only allows Ocx controls that can align themselves to a border. These are Toolbar, StatusBar, Scroll, Slider, ProgressBar, and Form Ocx.

The following AlignBarConst values are allowed:

Value AlignBarConst Meaning
0 basNoAlign None - size and location can be set at design time or in code.
1 basTop Top - object is at the top of the form, and its width is equal to the form's ScaleWidth property setting.
2 basBottom Bottom - object is at the bottom of the form, and its width is equal to the form's ScaleWidth property setting.
3 basLeft Left - object is at the left of the form, and its width is equal to the form's ScaleWidth property setting.
4 basRight Right - object is at the right of the form, and its width is equal to the form's ScaleWidth property setting.

Ocx controls that are aligned at the border of the parent form (using Align) change the Scale settings of the parent. ScaleLeft = 0 and ScaleTop = 0 are set to the top-left pixel of the uncovered client area of the form using SetViewportOrgEx API. ScaleWidth and ScaleHeight are set to width and height of the uncovered area. The mouse coordinates returned from MouseX, MouseY and that are passed in the forms MouseMove, MouseUp, and MouseDown events are relative to the new origin.

Example

Debug.Show

ParentW 1

Ocx ToolBar tb

Ocx StatusBar st

Ocx Form ofrm = , , , 200, 10

ofrm.Align = basLeft

Set Me = Win_1

Trace Me.ScaleTop

Trace Me.ScaleLeft

Trace Me.ScaleHeight : Trace _Y

Trace Me.ScaleWidth : Trace _X

Do

Sleep

Until Me Is Nothing

Remarks

The Align property overrules the Orientation property (Slider).

See Also

Form, ToolBar, StatusBar, Scroll, Slider, ProgressBar

{Created by Sjouke Hamstra; Last updated: 23/09/2014 by James Gaite}