@ ... Class

The @ ... Class command allows you to create objects programmatically on a form. We recommend using the Form Designer rather than this command.

Usage

@ nRow, nColumn CLASS cClassName NAME nObjName

Parameter

Value

Meaning

nRow

Numeric

Row on which the object should appear. Equivalent to objName.Top.

nColumn

Numeric

Column in which the object should appear. Equivalent to objName.Left.

cClassName

Character

Name of a FoxPro built-in class or a hand-coded class definition.

nObjName

Character

The name for the object. The object's properties, events and methods can be referenced using this name.


We think Microsoft supplied this command to offer a method of converting your code gradually into the OOP way of doing things without having to convert hand-coded interfaces into the visual Form Designer all at one time. By changing your code from @...SAY and @...GET to @...CLASS, they probably thought you could start to use the more intuitive properties, events and methods without having to learn all of the kinks of using Forms. This might be a good idea under some very specific circumstances, but generally we advocate skipping this command and going right for the Form Designer. The Form Designer offers far more capabilities, and will be more easily maintainable than this odd duck of a command. What Microsoft has supplied here is a command with its own, different kinks from those you're going to have to learn sooner or later, anyhow. This command does require a READ command to activate the controls. Also, don't be surprised if the controls appear inside a Pageframe1, on a first (and only) Page1, automagically added to your form when you issue the @ ... CLASS command.

Example

ON KEY LABEL F11 CLEAR READ
oForm = CREATEOBJECT("Form")
oForm.Show()
@ 10,10 CLASS "TextBox" NAME txtMyTextBox
oForm.PageFrame1.Page1.txtMyTextBox.Value = "Ta-da!"
oForm.PageFrame1.Page1.txtMyTextBox.BackColor = 255
READ  && press F11 to get out of this weird READ

See Also

Read


Back to Table of Contents

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