The Application Framework is designed, specifically, to include all necessary, and many optional, elements that make an application effective and pleasurable to use. Though the framework itself provides a great deal of flexibility and power to create applications the way that works best for you, this topic discusses the ways using the Application Wizard and the Application Builder ease your application development.
This topic includes the following sections:
Describing Application Functionality
Customizing the Application Framework
Extending Application Development
After you run the Application Wizard you will have an open project containing a number of files that comprise the application framework. The framework manages the following tasks for you:
The framework helps you answer questions about what your application does, how users input data, what kind of application the user sees, and how to add the greatest functionality.
Because data is a critical part of your application and can impact performance, its important to know about proper database design and optimizing techniques. Your datasources can be Visual FoxPro tables, or remote views to back-end hosts such as SQL Server. Also, you should consider issues presented by any multi-user requirements of your application .
The Application Builder allows you to use your existing data, or generate a new database with template tables for your specific application needs. The Adding Data topic describes how to integrate data in your application.
Data input is the first activity performed with a database application, and you should decide how you want users to enter data. Typically, a data-input form is used for entering data. Because of potential conflicts when multiple users edit the same data, the most common continuing activity of your forms in multi-user environments is properly handling conflict resolution.
You should choose the type of form that is appropriate for your application based on the structures of your data. You might have a simple datasource where a single table form is sufficient. Other situations may dictate using a more complex 1-to-Many form.
The Application Builder provides program code to add existing or new forms for the application framework. The Builder also lets you control how these forms integrate with the application.
See Managing Documents for more details on adding forms to your application.
In addition to input, your application must support display of data, often achieved through reports. Applications tend to be in one of two styles, input intensive or output intensive. Output-intensive applications often contain many reports and facilities for analyzing and manipulating data.
See Managing Documents for more details on adding reports to your application.
After you deal with the data specifics, you can choose a style for your application. The style or type you select depends on the context of your application. Your application can run as the sole application in the Visual FoxPro window, as part of another application, or as a top-level application without the Visual FoxPro desktop.
Use options in the General tab of the Application Builder to specify whether your application is to be a Normal, Module, or Top-level application.
Most Windows applications have several standard features, such as a Splash screen, About dialog box, a standard toolbar, and a Help file. In addition, some applications have a Quick Start dialog box, User Login dialog box, and a Favorites menu.
The application framework supports these common application features and assists you in choosing which features you want. The General tab of the Application Builder lets you provide information such as credits and version information, which is used by some of these options.
By using exclusive features of the Application Builder, you can create a fully functional and useful application. The Application Builder leverages the power of several wizards including the Form Wizard, Report Wizard, Database Wizard, and Table Wizard to simplify this process without any additional coding required.
You might want to extend functionality beyond the applications you can create with the Application Builder by using the Component Gallery and Foundation Classes. Visual FoxPro ships with over 100 foundation classes you can use to easily add effective enhancements to your application. These include data lookup and query-by-form controls, web hyperlinks, navigation toolbars, special effects, and offline data handles. The Component Gallery also contains other useful components such as ActiveX controls and COM components for use with your application.
When you are ready to build and package your application, the Application Builder enables you to build, test, and modify the application at any time. Since the Application Builder is reentrant, you can easily update the original design and incorporate requests for added functionality.
The Project Manager handles all necessary files during the build process. You can choose to either build an .exe or .app file. Usually, you will select the EXE option when you are ready to distribute to users because it uses the Visual FoxPro runtime files.
The last step is to create a distributable application package using the Setup Wizard. To do this, create a new folder and place in it your .exe file, data files, and any other files not compiled into the .exe. When you run the Setup Wizard using this folder, it will create all the necessary files for distribution including any extra system files.
After you plan your application, you need to select the data sources you need in developing your application. You can use the Application Builder Data tab to add databases and tables to your application and project.
If you already have existing data, you can use the Data tab to create a data environment for your application by adding free tables or tables from a database to the application. As soon as you specify a table, the Application Builder displays it in the grid and prepares to create both a form and a report for the table. At this point, you have selected only which data sources to include. They are not actually added to the framework until you select the Generate button. If you want to add only the data source and not have new forms or reports, uncheck the options next to the table entry. If you have a form or report check box marked when you click the Generate button, the appropriate wizard creates a new document for that datasource. You can select a visual style for these documents from the Style drop-down lists.
You can later edit these documents in the Form tab or Report tab of the Application Builder. If you have datasources listed in the Data tab grid and you click the OK button to exit the Application Builder, Visual FoxPro prompts you to add the tables, forms and reports to your project and application. Clicking the Generate button performs the same function.
The documents generated by the Application Builder contain all the fields for the selected datasource. If you want more control over the layout of your document, run the Form Wizard or Report Wizard directly from the Wizards menu and add the newly created document in the Form tab or Report tab. You can also add or edit forms or reports from the Application Builder.
When you use the Application Builder to add data, it is marked in the project as Excluded, meaning that it is not bound into the built application. This enables you to edit the added table. A table built into an application is read-only and cannot be edited. If you want to include a table in the project and thereby make it read-only (for example, a special lookup table where data will not change), right-click on the table in the Project Manager and select the Include menu item.
You can also use the Database Wizard or the Table Wizard buttons on the Data tab to create new tables to add to the project and application. These wizards create new data structures for your application in the appropriate data folder and allow you to generate new documents in the same manner discussed previously.
The basic documents that the Application Builder creates contain all fields in the tables on which they are based. These documents are excellent for basic data input and reporting, but you might want to create documents for other unique purposes in your application. The Form Wizard and Report Wizard offer more flexibility and the foundation classes included with the Component Gallery offer added functionality to forms and reports.
If you use the Application Builder to add data and documents to your application, data-binding is handled automatically. The Application Builder does, however, offer a Default Data Directory option on the Advanced tab if you are manually coding documents to bind to data and need the application framework to handle data path resolution. Use this setting to specify a folder that contains your datasources to provide appropriate path information for this data.
With many applications, you may already have data that you wish to use, but it's not necessarily in the proper format. It might be in plain text or spreadsheet format. In these cases, you can use the Import Wizard to migrate your data into FoxPro tables. You can then easily add these tables to your application.
Visual FoxPro includes an upsizing wizards that allows you to move your FoxPro data to SQL Server or Oracle databases. If the demands of your application require use of one of these databases, you can easily migrate your existing data and still keep the application intact.
The Oracle Upsizing Wizard and SQL Upsizing Wizard provide an option that allows you to Create remote views on tables. If you select this option, the tables in your database will be changed to remote views. Since the documents (forms or reports) in your application are bound solely to the datasource name, you can still run your application, but the data being used will be SQL Server or Oracle data instead of FoxPro tables.
If you have existing SQL Server or Oracle data that you want to use in your application, you can easily set up a Visual FoxPro database containing remote views pointing to these datasources. The application framework will handle these just like they were native FoxPro tables.
Once you have selected data sources, you need to plan and choose the documents that you want to add to your application. The Application Builder is particularly effective for this task since it not only adds the document to your project, but also integrates it with the framework. Because the framework uses extended document information stored in a meta-table, the Application Builder automatically handles this integration. The meta-table is stored in same folder as the application project and is given the same name as the project plus an _app.dbf suffix. The extended document information that is stored in the framework meta-table specifies the following:
You can have the builder automatically create new forms and reports when you add data to the application. These documents are generated from the associated wizards.
Once a document has been added to the application framework, it will automatically appear in the Forms tab or Reports tab.
When you open the Forms tab you will find a list that contains the forms you have already added to your application manually or from entries in the Data tab.
Note It's possible that a form in your project does not appear in the Forms tab. This is because that form is not registered in the application meta-table. You can register it by choosing the form using the Add button on the Forms tab page. In addition, the Cleanup button on the Advanced tab will synchronize the documents in your project with those registered in the meta-table. You can also edit or remove any of these documents from the appropriate tab.
To add documents in the Application Builder
The Forms tab enables you to manage the following options:
The Reports tab enables you to manage the following options:
To edit documents in the Application Builder
Would you like to add a mediator object to this form to fully enable it for use with the application framework?
If you answer "Yes", the Application Builder adds to your form an object that automatically communicates directly with the application object used by the framework. This object provides additional functionality to forms in your application. For example, when you close a form, the object can detect if there is buffered data that has not been saved and prompt you to save changes. Also, the object will also differentiate between a form launched using the New dialog box versus the Open dialog box.
In the designer, edit your document to your liking. You might want to use the Component Gallery to add a background or foundation class. You can use the Component Gallery to add special characteristics and functionality to your document.
To remove documents in the Application Builder
Important Your application will run regardless of whether a form or report is stored in the meta-table. As long as you provide code that specifies how to run this document, the application will handle it just fine. The advantage of using the Application Builder is that you would not need to worry about the application handling running forms and reports. This is done automatically.
Before discussing the general options available for your Application, lets take a quick look at how the application works:
Application Startup Applications often have a Splash screen that displays during startup, showing information about the application. The Application Builder controls both the screen itself and information contained within it.
User Login - When the application first launches, it might prompt the user to enter a login id and password. You can set this option in the Application Builder.
Quick Start You might want to display a dialog box of available documents for the user to select from immediately after startup. You can set this option in the Application Builder.
Opening Forms One of the primary functions of a database application is data input. Visual FoxPro accomplishes this in forms. The application framework uses a metaphor similar to that of Microsoft Office where the application is document-centric. The application framework provides a standard File Open menu item that runs your form, displaying existing data from your datasource. The framework also provides a File New menu that displays a form containing a new (blank) record.
Important If you are adding your own forms to the framework, you will need to manually specify the action of a form when launched from the File New menu. Forms generated by the Application Builder and Form Wizard automatically handle new record insertions for you.
Editing Records During an editing session, the application framework provides much of the common database functionality for you. If you attempt to close the application while a buffer contains unsaved data, the application will prompt you to save changes first. This functionality is handled when you attempt to close a form or application. There is also a Navigation toolbar and Go menu that lets you:
Printing If you have an open data input form, you can select the Print menu option, which prompts you with a selection of output options for the current data source. These include the following:
Running Reports The Print Reports menu option displays a dialog box of available reports for you to run. Once you select a report, the output dialog box opens to provide the following options:
Favorites The application framework supports a Favorites menu common to many web applications today. Because you can have multiple users if you choose the User Login option, items that appear in the Favorites menu are context sensitive to the user. The Favorites menu can contain any common Visual FoxPro document such as a Form, Report, Label or Program file. In addition, you can also click on the Browse button to select other types of documents such as Word, Excel, and HTML files.
Miscellaneous The application framework also supports some common Windows application features. These include:
Application Maintenance and Debugging The framework detects whether the application is being run under the Visual FoxPro runtime version or full development version. If run under full development version, a Program menu is displayed for debugging purposes. The menu items include many of the common Visual FoxPro debugging tools such as Debugger, Command window, and Class Browser.
The application also contains excellent error handling. The error handler writes details of the cause of the error and state of the application to a log table. The user can access the error log by choosing the Error log option of the application Tools menu.
Here is a summary of the application contents provided through the menus:
Menu | Options |
File | New, Open, Close, Save, Revert, Print, Print Reports, Print Setup, Quick Start, User Login, and Exit |
Edit | Undo, Redo, Cut, Copy, Paste, Clear, Select All, Find, Find Again, Replace |
Tools | Macros, Error Logs, Options, Change Password |
Program | Do, Cancel, Resume, Suspend, Compile, Debugger, Data Session, Command window, Class Browser |
Favorites | Add to Favorites, Clear Favorites |
Window | Cascade, Arrange All, Cycle |
Help | Help, About |
The application framework is designed to run without any need for the user to ever modify a menu. The framework will choose the appropriate menu for your application based on the type selected: Normal, Module, or Top-Level. However, this should not prevent you from modifying any of these menus if your application needs demand more than what the default menu offers. The application framework will run the menu fine with your modifications.
You can use the Application Builder General, Credit, and Advanced tabs to change characteristics of the application framework.
Use the General tab to change common application settings such as friendly name, application image, application type, icon, common dialog boxes such as Splash screen, About, Quick Start, and User Login dialog boxes
Use the Credits tab to provide information that will appear in the Splash screen and About dialog box of your application. These settings, can include author and company name, application version, copyright, and trademark.
Use the Advanced tab to specify a Help file and default data directory for your application. You can also choose to eliminate the standard toolbar and a Favorites menu from your application.
It is important to remember that while the Application Builder is reentrant, changes made through the Builder will not appear in the application until it is rebuilt.
Once you have created your application, you can use it as is and distribute it if you like. You will often want to add a little extra spice to what is in the typical application. Visual FoxPro has a number of useful tools to assist in this process. These include:
Wizards
Builders
Class Browser
Component Gallery
Visual FoxPro Foundation Classes
Create a new form The Component Gallery contains a number of form templates in the Visual FoxPro catalog that let you select certain fields from a datasource. The template dialog box includes an option to have the generated form automatically added to your project. If you desire a more complex form such as a 1-to-Many form, choose the appropriate Form Wizard.
Add a hyperlink to a form The Visual FoxPro catalog contains a number of hyperlink classes in the Internet folder. You can select a hyperlink label, image or button. When you drag-and-drop the control onto a form, a builder opens prompting you for the caption and target URL. In addition, the Component Gallery includes a WWW catalog containing a variety of common web sites. If you find here a web site you like and for which you'd like to create a hyperlink, drag-and-drop that item to your form (or choose Add to Form from shortcut menu).
Add Wallpaper to your form - The Multimedia catalog contains a number of images as well as access to the entire Visual Studio media gallery. With your form already open, create form wallpaper by right-clicking on the desired image then selecting Select Form Wallpaper from the shortcut menu.
Alternatively, you can drag the image from the gallery and drop it on the form to create an Image control on your form.
Add an ActiveX control to your form The ActiveX catalog contains a list of all registered ActiveX controls. If the Installed Controls folder in your catalog is empty, click the Installed Controls item and, from the shortcut menu, select Refresh Controls. The Property dialog box for this item provides the option to refresh from all controls in your system, or only those registered in the Visual FoxPro Options dialog box.
Drop a data-bound grid to your form The Component Gallery lets you create Data items in any catalog. A form displays a grid when you drag-and-drop one of these tables or views onto it. You can also try examples from the Testdata database in the Visual FoxPro catalog.
Add a video image to your report The Visual Studio media gallery in the Multimedia catalog contains a number of videos you might want to use in your application. You can simply drag-and-drop one of these files onto a form or you might add the Video Player class and select a video of your choosing.
Add a shortcut menu to your form The Visual FoxPro catalog contains several shortcut menu classes in the Menus folder. You can use the Navigation Shortcut Menu class on any form to add record navigation functionality. You can use the Shortcut Menu class to create any kind of shortcut menu.
Incorporate a thermometer to show progress of an activity The Thermometer form class in the Dialogs folder is similar to the common thermometer used internally by Visual FoxPro. You can use this class to show progress of an operation that takes some time to perform.
Create a new report The Component Gallery contains a number of report templates in the Visual FoxPro catalog that let you select certain fields from a datasource. The template dialog includes an option to automatically add the generated report to your project. The Report Wizards offer most options including summary and grouping features as well as support for percent-of-total type reports.
Add highlighting effects to your forms The MouseOverFx class can provide the raised-control look of Microsoft Office 97 toolbars to any form or toolbar.
Send email from a form button The MAPI ActiveX controls let you automate email to your clients. You can also use the Send Mail class in the Buttons catalog to send the current record to an email address.
Lookup information in the Registry Use the Registry classes in the Utilities catalog for accessing critical Registry information. For example, you might need to find an ODBC driver or shared tool.
Output data to Word Mail Merge The Automation catalog contains a Mail Merge class that is used by the Mail Merge Wizard to output data to Word as a Mail Merge document.
Create a Web Browser for your application The Web Browser control in the Internet catalog can be the basis for your Visual FoxPro Web Browser form. The control allows you to integrate Visual FoxPro code with browser interaction. For example, you can intercept or log (and optionally redirect) URL sites before navigation. Webvwr.scx in the Vfp98\Ffc folder illustrates how simple it is to create this type of form.
Add a data mover to your form - The User Controls catalog contains an assortment of mover classes. A mover is a set of list boxes that enable you to move an item from one list box to another list box. With the data mover classes, you simply need to drop the class onto a form. These movers are similar to those used in the Visual FoxPro Wizards.
Output data to Excel Pivot Table The Automation catalog contains a Pivot Table class that is used in the PivotTable Wizard to output data to Excel as a Pivot Table document.
Create data-bound charts Start with the Graph By Record class in the Automation catalog to bind your chart to data, record-by-record. This and the Graph class share the engine used by the Graph Wizard.
Add Web Publishing to your application The new Web Publishing Wizard and Genhtml engine provide HTML generation tools for data. The wizard, a friendly layer on Genhtml, lets you select a variety of data layout and visual style options. You can create dynamic output so that the HTML updates as data changes.
This section describes the various files and classes used by the application framework to create a hypothetical application. You can skip this section if you do not plan to modify any of these classes. However, this section provides details of how your application works.
The following table lists files created and/or used by the Application Wizard for an application named Wines that tracks a wine collection. The Application Wizard creates files using a naming convention that incorporates the name of the application, as shown below in the table.
Application file | Description |
Wines.app | This is your application created from the Build dialog box. |
Wines.pjx (pjt) | This is your project file. |
Wines_app.dbf (fpt, cdx) | This is the meta-table which stores form and report information entered into the Application Builder. |
Wines_app.h | This include file contains a number of settings controlling the application framework, each of which you can set. |
Wines_app.log | This is a log file you can use to record changes during application development. |
Appuser.dbf (fpt, cdx) | If you choose to include User Login dialog boxes, this file is created to store password and user preferences (option settings and favorites). |
Config.fpw | Contains runtime startup settings including the ability to hide the Visual FoxPro desktop if the Top-Level form option is selected. |
Libs\Wines_app.vcx (vct) | These are the classes used by your application. They are subclassed from the _framewk library enabling you to modify these at will. Avoid editing the classes in _FRAMEWK if possible. |
Menus\Wines _main.mnx (mnt) | This menu is used when you set the application type to Normal. |
Menus\Wines _go.mnx (mnt) | This is the navigation menu used by forms when the navigation menu option is checked in the Forms tab of the Application Builder. |
Menus\Wines _top.mnx (mnt) | This menu is used when you set the application type to Top-Level. |
Menus\Wines _append.mnx (mnt) | This menu is used when you set the application type to Module. |
Progs\Wines_app.prg | This is the main program, the point from which an application starts. It performs the following functions: displays Splash screen, creates the application object, sets the application paths and settings, and starts the application. |
\Vfp\Wizards\_Framewk.vcx (vct) | The framework contains the core set of classes used by the application framework. These include common classes such as: splash and aboutbox dialog boxes, application object, userlogin, and standardtoolbar to name a few. Most of these classes are subclassed in the Wines_app.vcx library. If you make changes at all, change classes in Wines_app and not in _framewk. |
\Vfp\Ffc\_app.vcx (vct) | This foundation class library contains classes used to manage an application environment. |
\Vfp\Ffc\_base.vcx (vct) | This is the class library containing base classes that all foundation classes are subclassed from. |
\Vfp\Ffc\setobjrf.prg | This file is used internally by the classes in _base. |
\Vfp\Ffc\_reports.vcx (vct) | This foundation class library contains classes used to handle reporting and output. |
\Vfp\Ffc\_table.vcx (vct) | This foundation class library contains classes used to perform all data querying and navigation. |
\Vfp\FFC\_UI.VCX (VCT) | This foundation class library contains classes used to manage various user interface routines such as Windows management. |
In this example, the class library in which you would most likely want to modify the application framework is Wines_app.vcx. Here is a list of the classes.
Application-specific class | Description |
App_aboutbox | Provides an About dialog box. |
App_application | Manages all operations and events in the application |
App_changepassword | Provides a Password dialog box |
App_errorlogviewer | Provides an Error Log dialog box |
App_favoritepicker | Provides a Favorites menu and item picker |
App_navtoolbar | Provides data Navigation toolbar functionality |
App_newopen | Provides New and Open dialog box functionality |
App_options | Provides an Options dialog box |
App_reportpicker | Displays a dialog box to select reports for printing |
App_splash | Provides an application Splash screen |
App_standardtoolbar | Provides Standard toolbar functionality |
App_topform | Provides a form frame object with menus for Top-Level applications |
App_userlogin | Provides a User Login dialog box |
These classes enable you to create or access supporting forms and dialog boxes in your application.
Because the Application Wizard adds Visual FoxPro Foundation Classes to your application project, you can also change the basis of the form and reports that comprise your application.
You can use wizards to create new databases, tables, forms and reports for the project from which you create your application. You can use the Class Browser to subclass the classes from which your forms and other application objects and functionality are generated.