共用方式為


Including Resources in Applications

Visual FoxPro provides several resource files that extend the basic functionality of your applications, including FOXUSER resource files, API libraries, and ActiveX controls. If you use these files, you must include them in your project or distribution tree.

For details about how to include files in your setup program, see the help associated with the setup-creation program you are using. The setup creation program you use must create MSI setup packages using Windows Installer technology.

Including FOXUSER Resource Files

Visual FoxPro resource files store useful information for your application, including window positions, Browse window configurations, and label definitions. If your application relies on specific settings for any of these resource items, you must also distribute the FOXUSER database and memo files or the resource files you create specifically for your application. These resource files consist of a Visual FoxPro table with an associated memo file, usually named FoxUser.dbf and FoxUser.fpt.

Note   The FOXUSER resource file isn't the same as the locale-specific resource file that contains dialog boxes and error messages. The FOXUSER resource file stores application information such as macros you've defined; the locale-specific resource file stores system text strings.

Including External Library Files

If your application includes external library files such as ActiveX controls (.ocx files) or Visual FoxPro API libraries (.fll files), ensure they are placed in the appropriate directory in your setup package. You can distribute the Visual FoxPro file FoxTools.fll with your applications. For more information on creating external libraries to access the Visual FoxPro API, see Accessing APIs.

Including Active X Controls and COM Components

If you include ActiveX controls or have created an Automation server (a COM component) as part of your application, include any .ocx and .dll files in your project and ensure the necessary support files are installed to the proper location on the user's machine. Note that Windows 2000 Logo guidelines do not recommend installation of components to the Windows System directory. Note that you can only distribute ActiveX controls for which you are licensed. For Automation servers, you must also include registration files, such as type libraries (.tlb files) and registry files (.vbr files), with your application.

If you use your setup creation program to create the distribution disks, you can include these files automatically. When you do this, the setup creation program ensures that COM components are registered properly on the user's computer when the application is installed. For more information on including files in your setup creation program, see the help associated with the program.

All users can run forms containing ActiveX controls; however, your application cannot accomplish certain tasks if it is running under the run-time version of Visual FoxPro. Remember the following guidelines:

  • Your application must be running under a full version of Visual FoxPro to change forms, classes, or subclasses that include ActiveX controls.

  • Your application must be running under a full version of Visual FoxPro to add ActiveX controls to forms at run time. For example, the full version of Visual FoxPro is required to add the Outline control to a form by running the following code:

    PUBLIC frmOleNewForm
    frmOleNewForm = CREATEOBJECT("form")
    frmOleNewForm.Show
    frmOleNewForm.ScaleMode = 3
    frmOleNewForm.Addobject("NewOutline","OLEControl",;
       "MSOutl.Outline")
    

    Note   When a form is closed, controls added at run time aren't saved.

  • Your application can be running under either the run-time or full version of Visual FoxPro to add subclassed ActiveX controls to a form at run time. For example, you can define the RedOutline subclass from the Outline class, and distribute the subclass in Olelib.vcx; all users can then add the RedOutline control to a form by running the following code:

    PUBLIC frmOleNewForm
    frmOleNewForm = CREATEOBJECT("form")
    frmOleNewForm.Show
    frmOleNewForm.ScaleMode = 3
    SET CLASSLIB TO CURR() + OLELIB.VCX
    frmOleNewForm.Addobject("NewOutline","RedOutline")
    

Including a Configuration File

The configuration file, Config.fpw, can establish many default Visual FoxPro settings. For instance, you can change the Visual FoxPro title, the background color, and the way a user navigates with the keyboard.

If you want the configuration file to be read-only, place it in your project and mark it as included. If you want the configuration to be modifiable, place the file in your project and mark it as excluded. Then distribute the configuration file with your application or executable file, as a separate file. By default, Visual FoxPro looks for a configuration file named Config.fpw. However, you can specify a different configuration file name using the -C command-line switch when starting Visual FoxPro.

For more information about options that you can set in the configuration file, see "Using a Configuration File" in Customizing the Visual FoxPro Environment.

Including a Locale-Specific Resource File

If you're distributing your application along with the run-time version of Visual FoxPro, you might need to include a locale-specific resource file. This file contains the dialog boxes and other user-interface elements that Visual FoxPro uses to interact with the user. There's a different run-time resource file for each language in which Visual FoxPro is available.

For more information about using locale-specific run-time files, see "Distributing Locale-Specific Run-Time Files" in Developing International Applications.

Note   The locale-specific resource file isn't the same as the FOXUSER resource file, which stores application information such as macros you've defined. The locale-specific resource file stores system text strings.

If you are creating an application for Middle Eastern platforms, be sure to add VBAME.DLL file to your distribution set and have it installed in the Windows System directory.

Including Help Files

If you create graphical Help for your application, include the .chm or .hlp file in your application distribution directory so that your setup creation program can include it on your distribution disks. For details about creating help, see Adding Help to Your Custom Application.

Note   You cannot distribute Winhelp.exe or the Help files shipped with Visual FoxPro. For more information, see Removing Restricted Visual FoxPro Features and Files.

Including All Your Files

You can freely reproduce and distribute some Visual FoxPro files, graphics, and programs with the applications you create. For details, see Removing Restricted Visual FoxPro Features and Files.

Before you build your application, make sure that your project includes the necessary files for your application as well as any additional resource files, such as graphics files or templates.

The following table list files you can add to your project.

If you are Add these files to your project
Applying a custom configuration to your application Config.fpw
Applying custom settings to your application Foxuser.dbf and Foxuser.fpt
Distributing a .dbf-style Help file Your .dbf-style Help file

To add files to your application

  • Include the files in your project.

    If you don't want to change them in the distributed application, place the files in your project and mark them as included. The files are then read-only and cannot be modified.

    -or-

  • Add the files to your application directory to make them easily accessible to your setup creation program.

    If you want to modify them, place the files in your project and mark them as excluded. Then distribute them with your application as separate files.

For more information about creating a project, and including or excluding files in a project, see Compiling an Application.

See Also

Menu Options | Removing Restricted Visual FoxPro Features and Files | Protecting and Documenting Your Source Code | Preparation of an Application for Distribution