Company logo


Advice, tips, techniques and downloads for Visual Foxpro developers.

Home | Contact

Enable report toolbars at run-time

Visual FoxPro lets you open the report designer in your application. But can you be sure the correct toolbars show up?

VFP developers sometimes like to give their users access to the report designer at run-time. For the most part, this is no more difficult than executing a MODIFY REPORT command from within an executable. Too often, though, the report designer will appear correctly, but the related toolbars will be nowhere to be seen.

In general, to control the visibility of toolbars at run-time, you use SHOW WINDOW and HIDE WINDOW. For example:

HIDE WINDOW "Standard"

to hide the standard toolbar, and

SHOW WINDOW "Standard"

to make it visible again.

Unfortunately, these commands only work if the toolbar has already been opened during the current session. If it hasn't, VFP generates error 1714 (Window not defined). As you've got no way of programmatically opening the toolbars in the first place, these commands won't solve the problem.

Nor can you give the user access to the standard Toolbars dialogue from within an executable. It's true that you can create a menu with the Toolbars prompt on it, but this will be greyed out when you run the program.

The solution turns out to be quite simple. To understand it, keep in mind that the current toolbar status - that is, the visibility and location of the toolbars, and whether they are docked or floating - is stored in the VFP resource file. The resource file is in fact two files. By default, they are named FOXUSER.DBF and FOXUSER.FPT and can be found in the directory from which you launched the application.

With that in mind, here are the steps needed to ensure that the report designer toolbars are always visible at run-time:

  1. Launch Visual FoxPro. Close any toolbars that you don't want the user to see at run-time (such as the standard toolbar).
  2. Open the report designer. Go to View/Toolbars and manually open the two main report designer toolbars (Report Designer and Report Controls). Move these to a suitable location on the screen. If you wish, you can also open the Layout and Color Palette toolbars at this point, but this is not essential as the user will be able to open these from the Report Designer toolbar.
  3. Using Windows Explorer, visit the directory from which you launched VFP. Look for FOXUSER.DBF and FOXUSER.FPT, and make them read-only. (To make a file read-only, right-click on it, select Properties, and enable the Read-Only checkbox.)
  4. Quit the report designer and close VFP.
  5. Copy the two Foxuser files to the directory on the user's system from which your application will be launched.
  6. Launch the application on the user's system. When you open the report designer from within the application, you should see the toolbars just as you left them.

From now on, the user will be able to move the toolbars around, dock and undock them, and even close them. But because the resoure file is read-only, these settings won't be saved when the application exits, so the toolbars will always revert to their initial status when the application starts.

One last point. Be sure to remove the read-only flags on the original copies of the two resource files (that is, the copies in your VFP directory). If you don't, all the toolbars and windows in the development environment - including the command window, browse window, property sheets, etc. - will revert to their default settings whenever you launch Visual FoxPro.

Mike Lewis Consultants Ltd.  January 2001

More Visual FoxPro articles | Crystal Reports articles | Recommended books | Visual FoxPro consultancy | Contact us

FoxStuff is maintained by Mike Lewis Consultants Ltd. as a service to the VFP community. Feel free to download and use any code or components, and to pass around copies of the articles (but please do not remove our copyright notices or disclaimers).

The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications.

© Copyright Mike Lewis Consultants Ltd.