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.
We considered putting “Application” twice in the heading above because Application is one of the many FoxPro keywords with more than one meaning. It’s both a property and an object. Both refer to a VFP automation server, though. _VFP is a system variable that provides a reference to the Automation server.
Application.Property = uValue
_VFP.Property = uValue
uValue = Application.Property
uValue = _VFP.Property
Application.Method()
_VFP.Method()
Since VFP 5, VFP is an Automation server and has the ability to create custom Automation servers. What this means is that other applications can call on VFP and the servers you build with it, and tell them to do things. The Application Object
and the _VFP system variable both provide an object reference to the server object, letting you address it from within VFP.
In the development environment, we don’t need to use these two too much. When we do, we tend to use _VFP rather than Application, because it’s so much shorter to type. Most often these days, we use _VFP to grab the ActiveProject so we can check out all the new capabilities on that front. Another item you might want to mess with is _VFP.StatusBar, which controls the text on the status bar.
Starting in VFP 7, there are a few other properties you might need to deal with. The positioning properties (Top, Left, Height and Width) for _VFP are no longer the same as for _SCREEN. _VFP’s properties refer to the entire VFP area, while _SCREEN’s measure only the interior, client area. In addition, both _VFP and _SCREEN now have an hWnd property that provides a Windows handle to the application and its client window, respectively. With IntelliSense, it’s easier to explore the new properties or underused functions, such as EditorOptions or DataToClip().
In custom servers, these references are more important because they let you tailor the VFP environment in which the server lives.
oProj = _VFP.ActiveProject && Grab a reference.
Application.Top = 35 && Position VFP
Application.Height = 100 && and size it.
oApp = oObject.Application
Application is also a property of every VFP base class. It contains a reference to the VFP Application Object
that holds the object.
o = CreateObject("Form") && Create a form.
? o.Application.Name && Returns "Microsoft Visual FoxPro".
ActiveForm, ActiveProject, AutoYield, Caption, DataToClip, DefaultFilePath, DoCmd, EditorOptions, Eval, Forms, FullName, Height, Help Method, hWnd, LanguageOptions, Left, Name, Objects, OLERequestPendingTimeout, OLEServerBusyRaiseError, OLEServerBusyTimeout, Parent, ProcessID, Projects, Quit Method, RequestData, _Screen, ServerName, SetVar, StartMode, StatusBar, ThreadID, Top, Version, VFPXMLProgID, Visible, Width