ASelObj()

ASELOBJ() tells you which objects are selected in the Form or Class Designer. With these references, you can determine and/or change an object's properties. In addition, ASELOBJ() allows you to reach "through" an object to determine the object's container or the containing form's data environment.

Usage

nSelCount = ASelObj( ArrayName [, nContainer ] )

Parameter

Value

Meaning

ArrayName

Name

The array to contain the object references.

nContainer

Omitted

Get a reference to each selected object.

1

Get a reference to the containing object of the selected objects.

2

Get a reference to the data environment of the form.

nSelCount

Positive number

The number of elements in the array, which is the number of selected objects (or 1 for a container or data environment).

0

No objects were selected, or in the case of nContainer = 2, the object(s) selected is not on a form. The array is not created in this case.


ASELOBJ() is a key to writing Builders. It lets you determine what control or controls are selected when the user runs a Builder. The object references in the array let you modify the properties and methods of the selected objects based on user input.SYS(1270) is a first cousin to ASELOBJ(). It returns a reference to the object currently under the mouse and doesn't require that the object be selected.

Example

* Before typing the code below in the Command Window,
* open the Form Designer and place a few labels on the form.
* Select at least three labels.
= ASelObj(aObjects)
aObjects[1].Caption = "First Label"
aObjects[2].Caption = "Second Label"
aObjects[3].BackColor = RGB(255,0,255)
aObjects[3].ForeColor = RGB(0,255,0)
In a Builder, you can make this sort of change in code based on user input. With references to the form and data environment, you can make changes to those as well—for example, resizing the form to fit the controls it contains.

See Also

Create Form, Sys(1270)


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .