Hide the main VFP system window


Most VFP applications appear as forms within the main VFP system window and users work with the menu bar in that window. This is a good model for many traditional FoxPro systems because they tend to be the sort of large-scale applications which users spend the entire day with; things like accounts packages and stock-control systems. Sometimes though you want a more modern appearance where the application appears as a free-floating form on the main Windows desktop. This is not difficult.

You need to make two adjustments to your design to achieve this effect. The first is to free the VFP form from the confines of the main VFP system window; the second is to turn off the main VFP window.

Freeing the form is easy. Go to the Layout tab of the main form's properties window and change ShowWindow. This will be 0 (in screen) by default. Change it to 2 (As Top-Level Form). For the other forms in the application you have the choice of setting them to 1 (In Top-Level Form) or 2 (As Top-Level Form) depending on how you want them to behave.

Hiding the main VFP window is more difficult. The obvious way to do it is to set the Visible property of the screen object:

_screen.Visible = .F.

This will work but even if you make this the first line of the first program in your application, you will still see the VFP window flash on and then disappear. You need to turn the screen off before the application starts and the way to do this is to use the Config file.

Create a new Config.Fpw file and put this line in it:

SCREEN=OFF

Note that there is no underscore here. The Config file is not referring to the _screen object.

If you need to distribute this application then you must make sure that the users have the right Config.Fpw file. You can do this by including the file in the project and building it into the executable.

Go to the Text Files entry of the Other tab of the Project Manager, Add File and select Config.Fpw. Fox will now build this file into the executable and you will not need to distribute the config file itself.

It is always worth building the Config.Fpw file into the executable even if you are not using it to hide the screen. The executable will use the built-in file even if you have another Config.Fpw in the same folder as the executable. It is very difficult to open the FoxPro development environment if Fox has just read and processed a Config.Fpw file which has told it to turn the screen off. If you put the runtime Config.Fpw in another folder then VFP itself will use the local Config.Fpw and the executable will use the one which has been included in the project. Use the technique described here to make sure that your development environment is using the correct configuration file.

Back to FoxPro Developers' page

Hints & tips

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.
Autocomplete in VFP 9

Your Access database will look more impressive if you add custom toolbars...
Custom toolbars

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

More...
More pages of hints and tips for users of Microsoft FoxPro and Access databases.

Site Map