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:

[Command button on the VFP desktop]

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

*-- 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")

With _Screen
  .AddObject ('cmdBuild', 'commandbutton')
  Bindevent (_Screen.cmdBuild, "Click", oHandler, "Build")
  With .cmdBuild
   *-- Set the appearance of the button first ...
   .Caption = "Build"
   .Top = 10
   .Left = 10
   .Height = 27
   *-- ... then make it visible.
   .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 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.

Access Tips

FoxPro Tips

General Tips

 

Related Items

Alvechurch Data - Microsoft FoxPro and Access Database Development and Training

Alvechurch Data provide training and development support for businesses using Microsoft FoxPro, Visual FoxPro and Access databases.

Read More

Autocomplete in Visual Fox Pro

Autocomplete in Visual Fox Pro

The textbox class in Visual FoxPro 9 has a new Autocomplete property which shows the user the previous values that have been entered in that textbox.

Read More

FoxPro Functions

FoxPro has always had functions to read and write files at a low level.

Read More

Development Services

Alvechurch Data have fifteen years experience developing databases for small business use.

Read More

Training Services

Details of the training courses offered by Alvechurch Data.

Read More