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.

AlwaysOnTop, AutoCenter

These form properties control whether the form stays on top of other displayed forms and whether the form is automatically centered when it opens.

Usage

frmForm.AlwaysOnTop = lIsAlwaysOnTop
lIsAlwaysOnTop = frmForm.AlwaysOnTop
frmForm.AutoCenter = lStartsCentered
lStartsCentered = frmForm.AutoCenter

Forms with AlwaysOnTop set to .T. can’t go beneath forms where that property is set to .F., even if the second one is the active form. If you have multiple AlwaysOnTop windows, though, they can go over each other. (To see how an AlwaysOnTop form behaves, right-click on the Property Sheet and make sure Always on Top is checked, or, in VFP 3, push the pushpin on the Property Sheet.) An AlwaysOnTop form doesn’t prevent other forms from getting focus; it just makes it hard to use the other forms. Use the form’s WindowType property or Show method parameters to make the form modal and prevent others from getting focus.

Forms with AutoCenter set to .T. appear centered when they first start up. Setting AutoCenter to .T. when a form is running centers it on the spot, but setting AutoCenter to .F. doesn’t change the form’s position. AutoCenter doesn’t keep the user from moving the form, either—use Movable for that.

AlwaysOnTop is ignored at design-time, but in VFP 3, AutoCenter is not. Since it’s a pain to design a form that’s centered, if you’re working in VFP 3 you’ll probably want to set AutoCenter in the form’s Init method rather than in the PropSheet.

Example

* Form Init might contain:
This.AlwaysOnTop = .T.
This.AutoCenter = .T.

See Also

Form, Movable, Show, WindowType