VFP Tutorial - Build an Executable

The last stage in the tutorial is to build an executable. For this step we need the Project Manager back on the screen. If you are careful with the mouse then you can drag the Manager off the toolbar but it is very easy to drag a single tab instead of the whole manager. Being able to drag a tab off the toolbar is a useful feature during form design but it's not what we want at this stage. The easiest way to undock the Project Manager is to right-click on the docked manager and select Undock.

[Project Manager in Visual FoxPro]

Click the Build... button.

Build Options

The standard version of Visual FoxPro lets you build executables and DLLs which can be freely distributed without paying additional licence fees. Select the Win32 Executable option and select the Display Errors tick box. Then click OK to build the executable.

[Options to build an executable in Visual FoxPro]

You will be asked for the name of the executable. The default is for the executable to have the same name as the project and to be in the same directory.

The FoxPro development environment is not a verbose one. The cursor will change to an hourglass when the build starts and you may see progress messages flickering in the Status Bar as the build proceeds but that is all that will happen. There will be no message to say that the build has succeeded. If the cursor returns to normal without there having been any error messages then the build will have succeeded.

Running the executable

You can run the executable from within the FoxPro development environment by selecting Do from the Program menu or by typing Do Cd.Exe from the Command Window.

If you try to run the executable from outside the development environment then you will find that it just flashes on the screen and then disappears. This is because Visual Foxpro is event-driven. We need to start the event-processing loop to tell FoxPro to start looking for mouse and keyboard events as soon as the form is displayed.

Open the form from the Project Manager and double-click on the surface of the form itself. An edit window for the Load event of the form will open. We want to put some code into the Activate event so click on the combo box showing 'Load' and pick 'Activate' from the list of events. Type the following code into the edit window for the Activate event:

Read Events

This will start the event processing loop but we now need to stop the loop when the form closes. Double-click on the Close button and change the program code in its Click event to read:

Thisform.Release()
Clear Events

Save and close the form and use the Project Manager to build the executable again. You should now be able to close FoxPro altogether, navigate to the executable in Windows Explorer, and run the executable by double-clicking on it.

The site has more details on starting the event-handling loop.

Distributing a FoxPro executable

There are two ways of distributing a FoxPro application and both are beyond the scope of this tutorial. One is to use the Setup Wizard (or InstallShield Express in later versions). The other is to just copy the files required to the user's PC. The files are listed in the FoxPro help system (and on this site at foxfiles.html). Copy them all to the same folder as the executable program. A FoxPro executable does not use the same DLLs as any other Micosoft applications so distribution is usually very straightforward.

FoxPro distribution requires no royalties. Once you have built your executable you can distribute as many copies of the program as you like. There is no limit on the number of people who can use it and no per-seat licencing required for the users. This ease of distribution makes FoxPro a very effective tool for building custom databases.


Introduction | Environment | Project | Tables | Forms | Navigation | Executable

Access Tips

FoxPro Tips

General Tips

 

Related Items

Visual FoxPro Tutorial - Program control

Program control structures in Visual FOxPro

Read More

Visual FoxPro Tutorial - Do Case

Visual FoxPro Tutorial - Using the Do Case structure to control program execution

Read More

Visual FoxPro Tutorial - Program Code

Visual FoxPro Tutorial - Writing program code

Read More

Visual FoxPro Tutorial - Development Environment

The Integrated Development Environment (IDE) for Visual FoxPro

Read More

Visual FoxPro Tutorial - Form Designer

Visual FoxPro Tutorial - Using the Form Designer

Read More