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.backcolor
=
RGB(0, 0, 0)
_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
Public oHandler
Set Talk Off
oHandler = Newobject
("ClickHandler")
With _Screen
.AddObject
('cmdBuild',
'commandbutton')
Bindevent
(_Screen.cmdBuild,
"Click",
oHandler,
"Build")
With .cmdBuild
.Caption
=
"Build"
.Top = 10
.Left = 10
.Height = 27
.Visible = .T.
Endwith
Endwith
Set Talk On
Return
Define
Class ClickHandler
As Session
Procedure Build
Build Exe
webadmin.exe
From
webadmin
Recompile
Return
Enddefine
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.
|