Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Left, Top

These two properties together indicate the location of an object.

Usage

oObject.Left = nPosition
nPosition = oObject.Left
oObject.Top = nPosition
nPosition = oObject.Top

Left is the position of the left-hand edge of a form or control, while Top is the location of the top of the object. Both are measured in the current ScaleMode and are relative to the containing object. That is, Left for a control in a form is the distance from the left edge of the form.

You can move an object by changing its Left and/or Top values, except for controls contained in columns of a grid.

If you’re like us, you might expect MaxLeft and MaxTop to provide limits for the values of Left and Top. In fact, they don’t. They’re about the position of the form when it’s maximized.

Example

frmMyForm = CREATEOBJECT("FORM")
frmMyForm.Show()
frmMyForm.AddObject("chkMyCheck", "Checkbox")
frmMyForm.chkMyCheck.Visible = .t.
frmMyForm.chkMyCheck.Left = 10
frmMyForm.chkMyCheck.Top = 20
* now add another object under the first
frmMyForm.AddObject("chkMyOtherCheck", "Checkbox")
frmMyForm.chkMyOtherCheck.visible = .t.
frmMyForm.chkMyOtherCheck.Left = frmMyForm.chkMyCheck.Left
frmMyForm.chkMyOtherCheck.Top = ;
   frmMyForm.chkMyCheck.Top + 20

See Also

Height, MaxLeft, MaxTop, ObjToClient(), ScaleMode, Width