Database development and training for Birmingham and the midlands
Specialists in Microsoft Access and Visual Foxpro database training and development
I am happy to hear from existing clients but I am taking no new calls.
A button to build a project
Visual FoxPro is an object-oriented language and the development tool itself is object-oriented. The desktop is an object represented by the _screen keyword and has properties and methods in the same way as any other object. A simple use of these is to change the colour and font of the screen:
_screen.forecolor = RGB(0, 255, 0)
_screen.fontname = "Courier New"
This gives a retro green-on-black screen in typewriter font.
A more sophisticated technique is to treat the FoxPro desktop as a container and add objects to it at runtime. This example adds a command button to the the desktop as a useful shortcut during development work:
There are two stages to the job. The first is to add the command button to the desktop; the second is to bind its Click event to some useful code. In this case, it's the code that that will build the VFP executable from a project
*-- We don't want to see progress reports as the
*-- button object is created.
Set Talk Off
*-- Bind the click event to a handler
oHandler = Newobject ("ClickHandler")
.AddObject ('cmdBuild', 'commandbutton')
Bindevent (_Screen.cmdBuild, "Click", oHandler, "Build")
*-- Set the appearance of the button first ...
.Caption = "Build"
.Top = 10
.Left = 10
.Height = 27
*-- ... then make it visible.
.Visible = .T.
Set Talk On
Define Class ClickHandler As Session
Build Exe webadmin.exe From webadmin Recompile
The button saves the four or five mouse-clicks needed to build an executable from the VFP Project Manager. It might not save much time on a single build but the savings build up during the day.
Use the VFP startup technique described here to create this command button automatically as Visual FoxPro loads.