Microsoft FoxPro has always provided developer tools for application development within the FoxPro application and the XBase language. Visual FoxPro has added object-oriented language and behaviors. This version of Visual FoxPro includes an enhanced application framework and object creation and maintenance tools designed to aid rapid application development and to streamline your maintenance tasks.
This chapter discusses:
Enhanced Application Framework
The Component Gallery is a container for catalogs of software objects such as class libraries, forms, buttons, and so on. The Component Gallery also contains new Visual FoxPro classes. You can use the Component Gallery to organize components into object, project, application, or other groupings. These visual groupings are dynamically customizable so that you can use, duplicate, or rearrange components among several classifications within the Component Gallery. You can access a specific item from any of the places in the Component Gallery that you place a reference to that component. You can have several references in different catalogs or folders to a single object. For instance, a button might appear in one or more Component Gallery project categories (represented as folders), but might also be visible in a "Tools" category that holds references to all the buttons you use.
You can use the Component Gallery for all the functions provided by the separate Project Manager, Class Browser, and Form Controls toolbar. Each of the other Visual FoxPro components provides very specific focus to the projects or classes from within the special environment of either Project file or Class library. The Component Gallery allows you to manage the relationships between components and many of the behaviors of those components from either an abstract design level as well as from a more intimate development perspective.
You can drag and drop components within the Component Gallery and from the Component Gallery to projects or forms. You can also change properties of objects or classes from within the Component Gallery.
The Component Gallery can contain any Visual FoxPro element, including local and remote documents, files, or folders, Automation servers like Microsoft Excel and Word, and HTML locations and files. You can also include .prg files containing code snippets, classes, wizards, builders, or art.
To open the Component Gallery
-or-
You can use the Component Gallery to create Projects and Applications and to manage their development. Use the Component Gallery to arrange components within the Component Gallery or use the templates, builders, and wizards in the Component Gallery to create the project or application you want.
To create a project or an application from the Component Gallery
For catalogs and folders, select tabs and options for the change you want to make. For details, see Component Gallery Options dialog box.
You can move items in the right, Object, pane of the Component Gallery window to the desktop or to an open project or form. The Project Manager recognizes the item referenced by the Component Gallery item and places it in the proper location in the Project Manager. Component Gallery items placed on the desktop are nonfunctional. There is no desktop representation for the Database, Folder, and gallery items representing nonvisual files.
To move items from the Component Gallery
The Move icon, located in the upper-left corner of the Component Gallery window, changes according to what item you select.
When the Component Gallery cannot find the original item represented by the gallery item, a Find dialog box opens so that you can locate the item.
The following table identifies the gallery items included in Visual FoxPro and their default behaviors.
Component Gallery Item Type | Drag-and-Drop targets | |||
Project | Form | Screen | Controls | |
Class (_ClassItem) | 6 | |||
File (_FileItem) | ||||
URL (_UrlItem) | 1 | |||
Form (_FormItem) | 9 | 11 | ||
Report (_ReportItem) | 9 | 11 | ||
Program (_ProgramItem) | 11 | |||
Menu (_MenuItem) | 10 | 11 | ||
Image (_ImageItem) | 2 | 7 | 2 | |
Sound (_SoundItem) | 3 | |||
Video (_VideoItem) | 3 | |||
ActiveX (_ActiveXItem) | ||||
Data (_DataItem) | 4 | |||
Template (_TemplateItem) | 5 | |||
Catalog (_CatalogItem) | 8 | |||
Sample (_SampleItem) | ||||
Project (_ProjectItem) | 11 |
1 – Add hyperlink class
2 – Add an image class or set a Picture property
3 – Add a multimedia class
4 – Add a grid class
5 – Depending on the type (e.g., form) creates a new file and adds it to the project
6 – Creates an instance in Screen
7 – Sets the Visual FoxPro wallpaper
8 – Launches a new Gallery window with that catalog
9 – Add a Button class to launch a form/report
10 – Add a shortcut menu to a form
11 – Opens in a designer (modifies)
You can right-click on a selected item in the right, Object, pane to display an Item Shortcut menu containing all the action options for that item, including Add to Project or Add to Form options. Use the shortcut menu to modify or, in some cases, run the gallery item. The shortcut menus are characteristic for each type of gallery item. You can change some properties of the selected item by clicking Properties on the shortcut menu to open the Item Properties dialog box.
The Component Gallery folders represent an arbitrary grouping of gallery items. You can reassemble the gallery items using drag and drop or you can duplicate items into other folders. You can copy and rename a catalog or folder and reassemble the items it contains. There are few, if any, limits on how you can use, modify, or create catalogs or folders.
Since Component Gallery items represent real items that can be objects or classes, you can review or modify these classes by accessing the original object through the Component Gallery.
To review a class
This opens the Class Browser so you can view the properties and methods of the selected class.
To modify a class
This opens the class in the Class Designer.
You can use the Component Gallery to duplicate or modify forms and to add forms and other gallery items to a project.
To create a form from the Component Gallery
-or-
-or-
The default settings for catalogs and folders enable you to perform basic review and management with gallery items. If you want to modify characteristics of catalogs or folders, or if you want greater access to gallery properties, select Advanced editing enabled in the Component Gallery Options dialog box.
When you open the Component Gallery, the left, Catalog, pane displays the default catalog shipped with the Component Gallery. A catalog is a visual representation of items that belong to a Visual FoxPro or user-defined group of items. Within a catalog you can create folders to further organize subgroups of items. Items can be forms, queries, programs, templates, art files, sound files, or other objects. The Visual FoxPro Component Gallery default catalog includes items grouped into several categories, including forms, controls, and others. The default catalog also includes an empty folder named Favorites that you can use to create or copy gallery items into. You can also copy and rename the default catalog, or create your own catalogs.
Component Gallery catalog options are set for catalog content and opening behavior. Global catalogs can contain any Component Gallery item type. Default catalogs open automatically when you start the Component Gallery. For details, see the Catalogs tab of the Component Gallery Options dialog box.
The Component Gallery includes the following catalogs.
Catalog | Description |
VFPGLRY | Contains components used by other catalogs in the gallery. Contains all the catalogs shipped with Visual FoxPro. Default and Global catalog. |
Visual FoxPro | Contains the Visual FoxPro Foundation classes. Default catalog. |
Favorites | An empty folder. Global catalog. |
My Base Classes | Contains subclassed Visual FoxPro base classes. Default catalog. |
ActiveX | A dynamic catalog containing either a list of all registered ActiveX Controls or a list of all Visual FoxPro ActiveX Controls. Default catalog. |
World Wide Web | A collection of Web site URLs. |
Multimedia | A variety of images, sounds, and video items you can use in your applications. |
Samples | References to the Solutions, Tastrade, ActiveX Servers and Client/Server samples. |
When you click a catalog in the list view, the right, Object, pane, displays the contents of that catalog. You can open other catalogs by double-clicking the catalog in either panel. Several Catalogs are included in the Gallery folder.
You can customize the Component Gallery by changing the default behavior of catalog, folder, and gallery items through the appropriate Properties dialogs.
To create a Component Gallery catalog
To change a catalog or folder configuration
Gallery catalogs and folders, as displayed in the Component Gallery window Catalog pane, can represent URLs, folders, or files on your hard disk. You can view a Gallery folder as Web view or as an Explorer-level view, depending on the way you specify the name in the General tab of the Folder properties dialog.
You can specify URLs or files as Gallery catalogs or as Gallery items. When you configure an item as a Gallery folder, the item automatically opens as a Web view in the Object (right) pane when you select it in the Catalog pane.
To configure a Gallery catalog or folder as a web view
http:\\www.microsoft.com\
file:\\c:\my documents\testpage.htm
file:\\c:\my documents\Wordfile.doc
When you highlight the Eeb view icon in the Catalog pane, the toolbar changes to include Web navigation buttons. The Web view will reflect the settings of your Windows Explorer.
You can specify a directory as a Gallery folder or catalog that has characteristics of Windows Explorer.
To configure a Gallery catalog or folder as an Explorer-level view
C:\My Documents\
Note This specification creates a view of actual files, unlike other Component Gallery views. In this view you can delete files from your disk.
To create an Explorer-level view that maintains protection of displayed files, specify the target using a wildcard designation as in the following example:
C:\My Documents\*.*
Avoid using wildcards to create dynamic folders when you can expect to find more than 512 items, unless you have a fast machine with a large amount of RAM.
The Component Gallery is comprised of an interface, whose classes are contained in Vfpglry.vcx, and items that reference the following Visual FoxPro Foundation Classes.
Object | Description | Class library |
About Dialog | Provides a simple About dialog box for custom applications. | _dialogs.vcx |
ActiveX Calendar | A calendar control that can be tied to a date field. | _datetime.vcx |
Array Handler | Provides methods for handling array operations not performed by native product array functions. | _utility.vcx |
Cancel Button | Releases a form and discards any outstanding buffered data. | _miscbtns.vcx |
Clock | A simple clock control for a form or container. | _datetime.vcx |
Conflict Catcher | A dialog box for resolution of row conflicts encountered while editing under optimistic buffering. | _dataquery.vcx |
Cookies Class | A simple Web class for handling cookies between Web pages. | _internet.vcx |
Cross Tab | Generates a cross tab. | _utility.vcx |
Data Edit Buttons | A complete set of edit buttons (as used by Form Wizards). | Wizbtns.vcx |
Data Navigation Buttons | A Top, Next, Prev, Bottom navigation button group and the DataChecker class to check for conflicts when moving records. | _datanav.vcx |
Data Navigation Object | A nonvisual navigation object that other classes can use. | _table.vcx |
Data Session Manager | Manages data sessions and handles data updates. | _app.vcx |
Data Validation | Traps for data conflicts on buffered data. | _datanav.vcx |
DBF -> HTML | Converts a Visual FoxPro cursor (.dbf) to HTML. | _internet.vcx |
Distinct Values Combo | Performs a lookup of unique values from the controlsource field to populate a combo box. | _dataquery.vcx |
Error Object | A generic error handler that works for both object and procedural code. | _app.vcx |
Field Mover | A supermover list box that automatically loads fields from current data source. | _movers.vcx |
File Registry | Provides a set of registry functions that return application-specific information. | Registry.vcx |
File Version | Retrieves information from the version resource of a file. | _utility.vcx |
Filter Button | Displays dialog to specify a data filter on a particular field. | _table2.vcx |
Filter Dialog | A dialog that enables you to specify filter conditions on data. | _table.vcx |
Filter Expression Dialog | Creates an advanced filter expression dialog. | _table.vcx |
Find (Findnext) Buttons | A generic find/findnext buttonset. | _table.vcx |
Find Button | Locates a record based on specific criteria. | _table.vcx |
Find Dialog | A find dialog with simple options such as Field choice. | _table.vcx |
Find Files/Text | Uses the Filer.DLL COM object to search for files. | _utility.vcx |
Find Object | Creates a generic object that locates a record based on specified critereria. | _table.vcx |
Font Combobox | A combo box that lists available fonts. It is also used by tbrEditing and rtfControls classes. | _format.vcx |
Fontsize Combobox | A combo box that lists available font sizes. It is also used by tbrEditing and rtfControls classes. | _format.vcx |
Format Toolbar | Provides a toolbar for applying font formatting to text of the active control. | _format.vcx |
FRX -> HTML | Converts a Visual FoxPro reporting output (.frx) to HTML. | _internet.vcx |
GetFile and Directory | Retrieves both a file and a folder name. | _controls.vcx |
Goto Dialog Button | Creates a button that displays the Goto dialog box. | _table2.vcx |
Goto Dialog | Creates a Goto record dialog box. | _table.vcx |
Graph By Record Object | A navigation button group that allows you to refresh a new graph per record on the fly. | _utility.vcx |
Graph Object | Generates a Graph using the core Graph Wizard engine. | Autgraph.vcx |
Help Button | Displays the Help file as it starts searching for the specified HelpContextID. | _miscbtns.vcx |
Hyperlink Button | Launches a Web browser from a button. | _hyperlink.vcx |
Hyperlink Image | Launches a Web browser from an image. | _hyperlink.vcx |
Hyperlink Label | Launches a Web browser from a label. | _hyperlink.vcx |
INI Access | A set of registry functions that access old INI-style file settings. | Registry.vcx |
Item Locator | This button brings up a dialog to locate a record. | _dialogs.vcx |
Keywords Dialog | Creates a dialog like the Component Gallery keywords dialog. | _dialogs.vcx |
Launch Button | Launches an application with an optional document. | _miscbtns.vcx |
Locate Button | Displays a dialog to locate a record. | _table2.vcx |
Lookup Combobox | Performs a lookup of values in a field to populate a combo box. | _dataquery.vcx |
Mail Merge Object | Generates a Word Mail Merge using the core Mail Merge Wizard engine. | Mailmerge.vcx |
Messagebox Handler | A simple wrapper around the MessageBox function. | _dialogs.vcx |
MouseOver Effects | Highlights a contol as the mouse passes over it. | _ui.vcx |
Mover | Provides a simple mover list box class with move/remove buttons. | _movers.vcx |
Navigation Shortcut Menu | A shortcut menu that can be dropped onto a form. | _table2.vcx |
Navigation Toolbar | A set of navigation buttons in a toolbar. | _table2.vcx |
Object State | Determines the state of an object and saves/restores object property settings. | _app.vcx |
ODBC Registry | A set of registry functions that return ODBC-specific information | Registry.vcx |
Offline Switch | Provides a view of online data for use offline. | _dataquery.vcx |
OK Button | Performs a simple form release. | _miscbtns.vcx |
Output Control | Displays a complex dialog box that prompts the user for a reporting output option. | _reports.vcx |
Output Dialog | Displays a dialog box that prompts the user for a reporting output option. | _reports.vcx |
Output Object | Various reporting output options. | _reports.vcx |
Password Dialog | A simple Password dialog for custom applications. | _dialogs.vcx |
Pivot Table | Generates a Mcirosoft Excel Pivot Table using the core PivotTable Wizard engine. | Pivtable.vcx |
Preview Report | A generic button to run a report. | _miscbtns.vcx |
QBF | Provides a buttonset for Query-By-Form querying. | _dataquery.vcx |
Registry Access | Provides access to information in the Windows Registry. | registry.vcx |
Resize Object | Causes form objects to resize/move with the Form's resize event. | _controls.vcx |
RTF Controls | Provides a set of buttons for applying font formatting to text of the active control. | _format.vcx |
Run Form Button | A button that runs a form. | _miscbtns.vcx |
SCX -> HTML | Converts an .scx form to an HTML. | _internet.vcx |
SendMail Buttons | Uses the MAPI ActiveX Control to send a mail message from a form. | _miscbtns.vcx |
Shell Execute | Provides Windows Explorer double-click behavior. | _environ.vcx |
Shortcut Menu Class | This wrapper class dynamically creates shortcut pop-up menus. | _menu.vcx |
Simple Edit Buttons | Provides simple Add, Edit, Delete, Duplicate, Save, and Cancel buttons (as used by Form Wizards). | Wizbtns.vcx |
Simple Navigation Buttons | Provides a set of Next and Previous navigation buttons. | _table.vcx |
Simple Picture Navigation Buttons | This is a set of simple picture navigation buttons. | _table2.vcx |
Sort Button | Displays a dialog that enables you to perform an ascending or descending data sort on a particular field. | _table2.vcx |
Sort Dialog | Enables you to perform an ascending or descending data sort on a particular field. | _table2.vcx |
Sort Mover | This subclass of the supermover list box class automatically handles sorting of data. | _movers.vcx |
Sort Object | Performs a sort on a data source. | _table.vcx |
Sort Selector | Performs an ascending or descending sort based on the current control. | _table2.vcx |
Sound Player | This class loads and plays a sound file. | _multimedia.vcx |
Splash Screen | Provides a simple Splash Screen for custom applications. | _dialogs.vcx |
SQL Pass Through | Provides SQL Pass Thru and can allow you to execute stored procedures on your host database. | _dataquery.vcx |
Stop Watch | Provides a stop watch control for a form or container. | _datetime.vcx |
String Library | Performs various string conversions. | _utility.vcx |
Super Mover | Provides Move, Remove, Moveall, and Removeall buttons. | _movers.vcx |
System Toolbars | A manager class that handles and tracks Systoolbars. | _app.vcx |
Table Mover | This subclass of the supermover list box class automatically loads tables and fields from the current data source. | _movers.vcx |
Text Preview | Provides a viewer of output text. | _reports.vcx |
Thermometer | Provides a standard thermometer class. | _controls.vcx |
Trace Aware Timer | This is an application utility that determines whether the trace window is open. | _app.vcx |
Type Library | The main routine ExportTypeLib creates a text file with Typelib output. | _utility.vcx |
URL Combo | Creates a combo box for typing in a Web URL. It launches Microsoft Internet Explorer and navigates to the site. | _internet.vcx |
URL Open Dialog | Provides a dialog that creates a drop-down list that stores URL history. | _internet.vcx |
VCR Buttons | A Top, Next, Prev, and Bottom navigation button group. | _table.vcx |
VCR Picture Navigation Buttons | A set of VCR picture navigation buttons. | _table2.vcx |
Video Player | Loads and plays a video file using MCI commands. | _multimedia.vcx |
Web Browser control | A subclass of the Internet Explorer 4.0 Browser control, which provides hooks for Visual FoxPro code. | _webview.vcx |
Window Handler | Performs several common window operations typical of applications. | _ui.vcx |
For full details on these class libraries, see the Visual FoxPro Foundation Classes topic. You can get information on how to use the foundation classes in Guidelines for Using Visual FoxPro Foundation Classes.
The Component Gallery class library, Vpfgallery.vcx, provides the item types as classes.
Item type | Description |
Class (_ClassItem) | The generic item type for any Visual FoxPro class. This can be either from .vcx or .prg files. |
File (_FileItem) | This is any file. Visual FoxPro reads the Registry for shell functions and adds them to the menu. The gallery includes a look up routine that checks for specific extensions and redirects the item type.
The gallery supports UNC naming conventions for team development (sharing of Catalogs across networks). |
ActiveX (_ActiveXItem) | This is an ActiveX Control or Server such as an .ocx created by Visual Basic CCE or .exe/.dll created by Visual FoxPro. |
Data (_DataItem) | This is a Visual FoxPro datasource (.dbc, .dbf, View, etc.). |
Image (_ImageItem) | This is a File Item Type whose file has an image file extension such as .bmp, .jpg, .gif, .ico, .cur, .ani, and so on. |
Sound (_SoundItem) | This is a File Item Type whose file has either a .wav or .rmi extension. |
Video(_VideoItem) | This is a File Item Type whose file has a .avi extension. |
URL (_UrlItem) | This is a Web Item Type and includes Web and local documents such as HTML files or Visual FoxPro Active Documents. |
Sample (_SampleItem) | This is a File Item Type for files that run in Visual FoxPro and can be an executable Visual FoxPro file such as .app, .exe, .prg, .scx, or .frx files. |
Template (_TemplateItem) | This is a Script Item Type that opens a builder for the Visual FoxPro element represented by the type of the highlighted item, including forms and reports. |
Catalog (_CatalogItem) | This is a Component Gallery type that allows you to Add and Open Visual FoxPro catalogs. |
Form(_FormItem) | This is a type for Visual FoxPro forms (.scx). |
Report (_ReportItem) | This is a type for Visual FoxPro reports (.frx). |
Menu (_MenuItem) | This is a type for Visual FoxPro menus (.mnx). |
Program (_ProgramItem) | This is a type for Visual FoxPro programs (.prg). |
Project (_ProjectItem) | This is a type for Visual FoxPro projects (.pjx). |
You can use the Class Browser to examine the details of any of these classes.
For details on other classes used in the Component Gallery, see the Visual FoxPro Foundation Classes topic or use the Class Browser to examine the libraries in the Ffc folder.
The Visual FoxPro Component Gallery is described in the following table structure.
Field | Field Name | Type | Width | Index |
1 | TYPE | Character | 12 | No |
2 | ID | Character | 12 | No |
3 | PARENT | Memo | 4 | No |
4 | LINK | Memo | 4 | No |
5 | TEXT | Memo | 4 | No |
6 | TYPEDESC | Memo | 4 | No |
7 | DESC | Memo | 4 | No |
8 | PROPERTIES | Memo | 4 | No |
9 | FILENAME | Memo | 4 | No |
10 | CLASS | Memo | 4 | No |
11 | PICTURE | Memo | 4 | No |
12 | FOLDERPICT | Memo | 4 | No |
13 | SCRIPT | Memo | 4 | No |
14 | CLASSLIB | Memo | 4 | No |
15 | CLASSNAME | Memo | 4 | No |
16 | ITEMCLASS | Memo | 4 | No |
17 | ITEMTPDESC | Memo | 4 | No |
18 | VIEWS | Memo | 4 | No |
19 | KEYWORDS | Memo | 4 | No |
20 | SRCALIAS | Memo | 4 | No |
21 | SRCRECNO | Numeric | 6 | No |
22 | UPDATED | DateTime | 8 | No |
23 | COMMENT | Memo | 4 | No |
24 | USER | Memo | 4 | No |
A coverage application writes information about which lines of code in a file were run. A profiler application provides information about which lines actually run, how many times a line is run, duration, and more. Coverage and profiling enable a developer to identify problem areas in an application, especially skipped code and performance bottlenecks.
Visual FoxPro Coverage Profiler is provided in two parts – a Coverage engine you can use or customize, and a multiwindow application you can use to analyze programs and projects.
The Coverage Profiler application provides several ways to view the data provided by the Coverage Engine. Coverage.app is a subclass of the Coverage engine. You can automate coverage, or modify the User Interface to suit your needs, run Coverage Profiler in unattended mode and not display the application window, or use engine features without using the interface.
Upon startup the coverage application suspends coverage logging enabled with a SET COVERAGE TO command. When you release the coverage object, the application provides a choice to restore the SET COVERAGE setting.
Coverage Profiler uses a log file generated by Visual FoxPro when you use the Coverage option in the Debugger Tools menu or use SET COVERAGE TO as in the following command:
SET COVERAGE TO cCoverage.log
When you use the command, the ADDITIVE clause allows you to avoid overwriting an existing log. This command starts data streaming and opens the file cCoverage.log, a text file that will gather the stream of details on the file or application you examine.
A coverage log file consists of records in comma-delimited lines. The following list describes the structure of each record.
Item | Description |
1 | execution time |
2 | class executing the code |
3 | object, method, or procedure in which the code is found or called |
4 | line number within the method or procedure |
5 | fully defined file |
6 | call stack level (Visual FoxPro 6.0 only) |
After specifying the log file name, run the program or application you want to examine. When you end the program you can use the SET COVERAGE TO command to stop the data stream to the coverage log.
You can view the coverage log by starting Coverage Profiler from the Tools menu or by using DO as in the following command:
DO (_COVERAGE) [WITH cCoverage]
Visual FoxPro prompts you for the name if you do not specify a log file. The _COVERAGE System variable in Visual FoxPro 6.0 defaults to the Coverage Profiler application, Coverage.app.
To use the Coverage Profiler effectively, prepare your application and your environment carefully. If you use the following guidelines, the Coverage Profiler can provide accurate and useful information about your project or application.
To use the Coverage Profiler to examine application coverage
The Coverage Profiler application starts in Coverage Mode by default.
To use Coverage Profiler to examine application profile
If you find that you are most often interested in profiling, you can change the default to Profile Mode in the Coverage Profiler Options dialog box.
To use the Coverage Profiler with a specific log file
Run the coverage application using the WITH option and the log file name as in the following example:
DO (_COVERAGE) WITH "Mylog.LOG"
This example uses the log file Mylog.log and opens the Coverage Profiler application window to display the results. If you specify no file name, the Coverage Profiler uses the log specified in a current SET COVERAGE TO command or displays the Open file dialog box when coverage logging is OFF.
To use the Coverage Profiler without the User Interface
Run the coverage application using the WITH option and specify true (.T.) for unattended mode running as in the following example.
DO (_COVERAGE) WITH "Mylog.LOG",.T.
In this example, the Coverage Profiler application uses the log file Mylog.log and runs without displaying the Coverage Profiler application window.
To use the Coverage Profiler with a specific Add-In file
Run the coverage application using the WITH option and the add-in file name as in the following example:
DO (_COVERAGE) WITH "Mylog.LOG",, "add_ui.prg"
This example uses the log file Mylog.log and opens the Coverage Profiler application window to display the results, and then the Add-In program ADD_UI.PRG runs. The second, unspecified, parameter is a logical value that specifies whether the coverage engine operates in unattended mode. In the default setting, false (.F.), the Coverage Profiler window displays.
Besides viewing the profiler information, you can insert comments or markers and you can save the information as a file to use later.
By default the Coverage Profiler application runs in a separate window. You can reconfigure it to run inside the main Visual FoxPro window by changing the Environment Option. In the Coverage Profiler Options dialog box, change the Environment selection from Coverage frame to FoxPro frame, and then restart the Coverage Profiler.
You can also use the Coverage Profiler Options dialog box to modify the following Coverage Profiler characteristics.
Characteristic | Description |
Add-Ins | Specifies whether Add-Ins are registered in the Coverage Profiler as they are used. For more information, see the section, "Coverage Profiler Add-Ins." |
Coverage Marks | Specifies whether the Coverage Profiler marks code that is run or code that is not run. Specifies the character(s) used to mark code. Specifies when code is marked. |
Fonts | Specifies the fonts used in the Coverage Profiler as code and in displays. |
Smart Pathing | Specifies whether Coverage Profiler automatically seeks files in previously specified locations. |
Start Mode | Specifies whether Coverage Profiler opens in Coverage or Profile Mode. |
To help ensure that the files processed by the Coverage Profiler are the correct files:
Some lines in code, such as comments, DEFINE CLASS and ELSE statements, and lines within TEXT … ENDTEXT do not appear in coverage logs because they are not even potentially executable. Also, lines broken by continuation symbols (semicolons) are considered as a single line of code and marked only on the last line.
Add-Ins are code files (usually .prg or .scx) that provide an easy way for you to adjust the Coverage Profiler. The cov_standard subclass of the coverage engine which comprises the User Interface of Coverage.app shows only a small part of what you can do with the engine. The engine analyzes the coverage log; cov_standard just displays the results in one of many ways you could want to see them.
You could create a different subclass of cov_engine with a very different display. For example, your subclass might display a dialog that runs queries against the coverage statistics gathered by the engine. The display options might provide a view of the marked code for a filtered set of log entries, or only a graph of the profiling results.
You may not want to subclass cov_engine to create a new interface from scratch because the cov_engine class provides an easier process. You can add functionality to cov_standard, or any cov_engine subclass, using Add-Ins. Cov_standard exposes this feature through a button in the main dialog of Coverage Profiler. When you run an Add-In on an instance of cov_standard such as Coverage Profiler, the Add-In can manipulate the capabilities of cov_engine, the coverage tables, as well as cov_standard. Add-Ins might also add new dialogs and features to the cov_standard visual interface.
You can write Add-Ins to enhance the standard interface or you can subclass cov_standard to create your own wholly new interface.
The following list includes features you might want to provide through Add-Ins:
Note You can use the Adjust… methods (AdjustCoverageFilenameCursor( ), AdjustSourceCursor( ), and AdjustTargetCursor( )) of the Engine to add fields to the Source and Target tables when the engine creates them, and use these fields in your Add-Ins.
The modal dialog class cov_AddInDialog in the standard coverage engine subclass, presents previously registered dialogs in a drop-down list. When you set the coverage engine lRegisterAdd-In option ON, the full path name of successfully run Add-Ins are added to the Windows Registry so you can easily run these Add-Ins again. The Standard UI class also allows you to set this property in the Coverage Profiler Options dialog box.
The Coverage Engine object maintains a list of all registered Add-Ins in the aAddIns property.
When you write Add-Ins, consider the following information:
You can subclass either the coverage engine or its standard subclass. The following list describes the structure of the COVERAGE project source file set.
File | Description |
Coverage.prg | A "wrapper" for the coverage object, which instantiates the object. |
Coverage.vcx Coverage.vct |
All classes for the engine and its standard subclass. |
Cov_short.mnx Cov_short.mnt |
Shortcut menu. |
Cov_pjx.frx Cov_pjx.frt |
Default mechanism to deliver project-level results. |
Coverage.h | Header file for all Coverage code, incorporating the following elements:
*— Coverage character constants for log and parsing:
*— Coverage localized strings (can use some log and parsing constants):
*— Coverage common dialog component constants:
*— Coverage specs & requirements:
*— Coverage registry object constants:
*— Coverage tune-able options:
|
The COVERAGE project source file set also includes various .ico .bmp, and .msk files.
Use the file COV_TUNE.H (containing appropriate comments and explanations) to become familiar with options available to you without rewriting code.
Since Add-In use is governed by the coverage engine superclass, any other coverage subclass you create can use Add-Ins in the same manner as the standard subclass.
The coverage engine subclass instantiated by the default Coverage.app does not augment the coverage engine RunAddIn( ) method in any way. It does, however, invoke a modal dialog box to allow the user to pick an Add-In before it invokes the coverage engine RunAddIn( ) method. The modal dialog box receives a reference to the Coverage object and sets the coverage engine cAddIn property.
If you write your own coverage engine subclass, ensure that your subclass can use the same modal dialog class (cov_AddInDialog) to handle Add-Ins as the standard Coverage application; the dialog box does not rely on any features of the standard subclass.
You can call a different modal dialog box, set the cAddIn file name directly in the cAddIn property, or override the contents of the cAddIn property by passing the name of the Add-In file you wish to run to the RunAddIn( ) method.
However you access an Add-In to run in your subclass, you can investigate the list of Add-Ins registered to Coverage.app by checking the file names in the coverage engine aAddIns property.
For details on the Properties, Events, and Methods of the coverage engine, see Coverage Engine Object.
In previous versions of Visual FoxPro, the only access to a project was through direct table manipulation of the project’s .pjx file. In Visual FoxPro 6.0, you can access a project programmatically, allowing you to manipulate a project as an object. A project can be manipulated at design time while the project is open in the Project Manager, or at design time and run time without the Project Manager visible.
The following are some of the actions you can perform programmatically on a project:
With the new project manager hooks, advanced developer’s can create their own project managers with unique customized user interfaces.
The object hierarchy for a project consists of the project, a project object, and its associated ProjectHook object. A project object contains a files collection, consisting of files in the project, and a servers collection, consisting of Automation servers created from the project. The following diagrams illustrates the project object hierarchy within the Visual FoxPro object model:
The projects collection gives direct access to a project object, allowing you to manipulate the project and the files and servers the project contains. A project object is added to the projects collection whenever a project is created, opened or an .app, .dll, or .exe is built from the project.
Like other OLE collections, you can obtain information about a project from the projects collection. For example, the following code uses the projects collection Count and Item properties to display the names of all the projects in the projects collection, and then uses the FOR EACH command to display the same information:
nProjectCount = Application.Projects.Count
FOR nCount = 1 TO nProjectCount
? Application.Projects.Item(nCount).Name
NEXT
FOR EACH oProj IN Application.Projects
? oProj.Name
ENDFOR
This line of code uses the ActiveProject property to add a program, Main.prg, to the currently active project:
Application.ActiveProject.Files.Add('Main.prg')
This line of code adds Main.prg to the first project added to the projects collection:
Application.Projects[1].Files.Add('Main.prg')
A projects collection has the following properties and methods:
Properties | |
Count |
Methods | |
Item |
The project object is instantiated whenever a project is opened from the File menu or with the CREATE PROJECT, MODIFY PROJECT, BUILD APP, BUILD DLL, BUILD EXE, or BUILD PROJECT commands. The project object allows you to programmatically manipulate the project, and can be accessed through the Visual FoxPro Application object. Note that the Application object supports a new ActiveProject property that provides a project object reference to the project open in the currently active Project Manager.
A project object has the following properties and methods:
Methods | |
Build | CleanUp |
Refresh | SetMain |
A ProjectHook object is a Visual FoxPro base class that is instantiated by default whenever a project assigned to the ProjectHook object is opened. (You can include the NOPROJECTHOOK clause in CREATE PROJECT and MODIFY PROJECT to prevent a ProjectHook object from being instantiated for the project.)
The ProjectHook object allows programmatic access to events that occur in a project. For example, you can execute code whenever a file is added to a project.
You can specify a default ProjectHook class for new projects in the Projects tab of the Options dialog box. If a default ProjectHook class isn’t specified in the Projects tab, new projects aren’t assigned a ProjectHook class. You can specify a project hook class for an individual project (overriding the default ProjectHook class) in the Project Information dialog box. At runtime, you can use the ProjectHook property to specify a project hook class for a project. If you change the ProjectHook class for a project, the new ProjectHook class doesn’t take effect until the project is closed and opened again.
A ProjectHook object has the following properties, events, and methods:
Properties | |
BaseClass | Class |
ClassLibrary | Comment |
Name | OLEDropEffects |
OLEDropHasData | OLEDropMode |
Parent | ParentClass |
Tag |
Events | |
AfterBuild | BeforeBuild |
Destroy | Error |
Init | OLEDragDrop |
OLEDragOver | OLEGiveFeedBack |
QueryAddFile | QueryModifyFile |
QueryRemoveFile | QueryRunFile |
Methods | |
AddProperty | ReadExpression |
ReadMethod | ResetToDefault |
SaveAsClass | WriteExpression |
When you open the Project Manager from the File menu, or with the CREATE PROJECT or MODIFY PROJECT commands, the Project Manager window appears and a project object is instantiated with its associated ProjectHook object. Project build commands (BUILD PROJECT, BUILD APP, BUILD DLL, and BUILD EXE) also instantiate the project and ProjectHook objects.
When an event occurs in a project, the project object passes the event to the ProjectHook object. User code in the event in the ProjectHook object is executed and control is passed back to the Project object. The value returned to the project object from the ProjectHook object determines if the project object finishes the operation. Placing NODEFAULT in the event code prevents the default action from being performed. For example, placing NODEFAULT in the QueryAddFile event prevents a file from successfully being added to a project.
The files collection gives direct access to a file object, allowing you to manipulate file objects in a project while the project is open. Like other OLE collections, you can obtain information about a file in a project from the files collection. For example, the following code uses the files collection Count and Item properties to display the names of all the files in the files collection, and then uses the FOR EACH command to display the same information:
nFileCount = Application.ActiveProject.Files.Count
FOR nCount = 1 TO nFileCount
? Application.ActiveProject.Files.Item(nCount).Name
NEXT
FOR EACH oProj IN Application.ActiveProject.Files
? oProj.Name
ENDFOR
This line of code uses the ActiveProject property to add a file, Main.prg, to the currently active project:
Application.ActiveProject.Files.Add('Main.prg')
This line of code adds Main.prg to the first project added to the projects collection:
Application.Projects[1].Files.Add('Main.prg')
The files collection has the following properties and methods:
Properties | |
Count |
Methods | |
Add | |
Item |
The file object allows you to manipulate individual files in a project.
A file object has the following properties and methods:
Properties | |
CodePage | Description |
Exclude | FileClass |
FileClassLibrary | LastModified |
Name | ReadOnly |
SCCStatus | Type |
Methods | |
AddToSCC | CheckIn |
CheckOut | GetLatestVersion |
Modify | Remove |
RemoveFromSCC | Run |
UndoCheckOut |
The servers collection gives direct access to a server object, allowing you to manipulate the servers that a project contains. A server object is added to the servers collection whenever a .dll dynamic-link library or .exe executable file containing an Automation server is built from the project. For more information about creating Automation servers, see Creating Automation Servers in Chapter 16, “Adding OLE,” in the Programmer's Guide.
A servers collection has the following properties and methods:
Properties | |
Count |
Methods | |
Item |
The server object lets you determine information (including type library information) about Automation servers contained in a project. This information is also available in the Servers tab of the Project Information dialog box. Note that a server object isn’t created until the project containing the OLEPUBLIC class (specified in the DEFINE CLASS command) is built.
A server object has the following properties and methods:
Properties | |
CLSID | Description |
HelpContextID | Instancing |
ProgID | ServerClass |
ServerClassLibrary |
A Visual FoxPro project object exposes an IDispatch interface so that Automation clients, ActiveX controls, and other COM objects can access the project object through standard OLE interfaces. Because a project object now exposes an IDispatch interface, the errors that can be generated when manipulating projects are OLE errors.
Two new clauses have been added to the CREATE PROJECT and MODIFY PROJECT commands. The first clause, NOPROJECTHOOK, prevents the ProjectHook object from being instantiated for a project. The second clause, NOSHOW, opens a project without displaying it in the Project Manager, allowing you to programmatically manipulate the project without displaying it. You can use the Visible property to later display the Project Manager. For more information about these new clauses, see CREATE PROJECT and MODIFY PROJECT.
The following sections describe events and the order in which they occur when projects are created, modified, closed, built, and so on.
The following events occur when you execute CREATE PROJECT, create a new project from the File menu, or click the New toolbar button and specify to create a new project:
If the Init event returns false (.F.), the project isn’t created, the project and ProjectHook objects are released, and the Project Manager isn’t displayed.
The following events occur when you execute MODIFY PROJECT, modify an existing project from the File menu, or click the Open toolbar button and specify an existing or new project:
If the Init event returns false (.F.), the project isn’t opened for modification, the project and ProjectHook objects are released, and the Project Manager isn’t displayed.
The following events occur when an open project is closed:
The following events occur when BUILD APP, BUILD DLL, or BUILD EXE is issued:
If any files are added to the project during the build process, the ProjectHook QueryAddFile event occurs before each file is added. If NODEFAULT is included in the QueryAddFile event, a file isn’t added to the project. Otherwise, the file is added to the project. When the .app, .dll, or .exe is successfully built, the ProjectHook AfterBuild event occurs, and then the ProjectHook Destroy event occurs.
If the Init event returns false (.F.), the app, .dll, or .exe isn’t built, and the project and ProjectHook objects are released.
The following events occur when BUILD PROJECT with the FROM clause is issued. If the FROM clause is omitted, the events occur in the order described above when BUILD APP, BUILD DLL, or BUILD EXE is issued.
The ProjectHook BeforeBuild event then occurs. If NODEFAULT is included in the BeforeBuild event, the project isn’t built. Otherwise, the project is built. When the project build is complete, the ProjectHook AfterBuild event occurs, and then the ProjectHook Destroy event occurs.
If the ProjectHook Init event returns false (.F.), the project isn’t built. The project and ProjectHook objects are released and a new .pjx file isn’t created.
The following events occur when you drag a file or a set of files over the outline section (treeview) of the Project Manager:
The following events occur when you add a file to a project by clicking the Add button in the Project Manager:
The following events occur when you add a new file to a project by clicking the New button in the Project Manager:
The following events occur when you modify a file in a project by clicking the Modify button in the Project Manager:
The following events occur when you remove a file in a project by clicking the Remove button in the Project Manager:
The following events occur when you execute a file in a project by clicking the Run button in the Project Manager:
The following events occur when you rebuild the project or build an .app, .dll, or .exe from a project by clicking the Build button in the Project Manager:
The Visual FoxPro Solutions Sample application includes a sample named “Track activities in a project” that demonstrates many of the new Project Manager hooks.
To run the Solutions Sample application
DO (HOME(2) + 'solution\solution')
– Or –
To run the “Track activities in a project” sample
The “Track activities in a project” sample allows you to open a project and then manipulate the project in any manner. Any changes you make to the project are stored in a table. When you close the project, you can view the changes you made to the project in a Browse window.
For more information about how the “Track activities in a project” sample works and to take a closer look at the code behind the sample, you can open the form used to create the sample.
To open the “Track activities in a project” form
Acttrack.scx, the form used to create the “Track activities in a project” sample, is opened in the Form designer.
You may also want to take a closer look at the ProjectHook class library, Project_hook.vcx, that is assigned to the project you open in the “Track activities in a project” sample. Most of the code that is executed when project events occur is in the event procedures in this class library. Project_hook.vcx is located in the …\Samples\Vfp98\Solution\Tahoe directory.
The following wizards and builders are either new or enhanced.
The Application Wizard for Visual FoxPro 6.0 provides support for the enhanced Application Framework and the new Application Builder. You can run the Application Wizard from the Component Gallery or from the Visual FoxPro Tools menu by clicking Wizards and then Application.
Note The Application Wizard (5.0) from Visual FoxPro 5.0 is available from the Wizard Selection dialog box for backward compatibility.
The Connection Wizards include the Code Generation Wizard and the Reverse Engineering Wizard. These wizards let you easily manage transfers between Visual FoxPro class libraries and Microsoft Visual Modeler models.
Database Wizard New
The Visual FoxPro Database Wizard uses templates to create a database and tables. You can also use the wizard to create indexes and relationships between the tables in a new database.
Documenting Wizard Enhanced
The Visual FoxPro Documenting Wizard now provides an option to use the Code Analyzer as documentation is created.
Form Wizard Enhanced
The updated Visual FoxPro Form Wizard provides input mask, format, and a field mapping class for specific fields as stored in a database. This wizard also includes more form style options, including scrolling forms.
Graph Wizard Enhanced
The Visual FoxPro Graph Wizard creates a graph from a Visual FoxPro table using Microsoft Graph. This updated wizard supports the Graph 8.0 component of Microsoft Office 97, including automation of the datasheet and the Series by Row/Col option.
Import Wizard Enhanced
The updated Visual FoxPro Import Wizard supports Office 97 and Microsoft Excel multisheet handling and provides the option to import a table to a database.
Label Wizard Enhanced
The Visual FoxPro Label Wizard now includes greater control of label fonts and direct access to the Add Label Wizard.
Mail Merge Wizard Enhanced
The Visual FoxPro Mail Merge Wizard creates either a data source for a Microsoft Word merged document or a text file that can be used by any word processor. This updated wizard supports the Microsoft Word 8.0 component of Office 97 and true VBA Automation with Application object and collection support.
Pivot Table Wizard Enhanced
The Visual FoxPro PivotTable Wizard helps you create interactive worksheet tables that summarize and analyze data between two or more fields in a table. This updated wizard supports the Microsoft Excel 8.0 component of Office 97. You can choose either to save a pivot table directly in Excel or to add one as an object on a form.
Report Wizard Enhanced
The Visual FoxPro Report Wizard now includes advanced grouping and summary functionality so you can more easily customize your reports inside this single wizard. There are also more report styles to choose from.
Remote View Wizard Enhanced
The Visual FoxPro View Wizard now provides access to System tables so you can use the functionality of ODBC drivers that support these.
Sample Wizard New
The Visual FoxPro Sample Wizard provides simple steps to creating your own wizard. The output is an HTML file created from records in the data source you specify.
Setup Wizard Enhanced
The Visual FoxPro Setup Wizard now provides enhanced support for ActiveX controls and override of the Windows file number limit for use in NT setups. It also enables you to add external .DLLs to your application through the setup and to create Web-based installs.
Table Wizard Enhanced
The Visual FoxPro Table Wizard now provides new table templates, optional style settings, support for both Character and Memo binary data types, and access to databases. You can add your table to a database and you can use database settings to determine the formats of fields you add to your table. You can also establish relationships between tables in the database.
The Visual FoxPro Web Publishing Wizard generates an HTML file created from records in the data source you specify.
The Visual FoxPro 6.0 Application Framework is designed to make it easier to develop Visual FoxPro applications. You can access the enhanced Application Framework through the Application Wizard or through the New Application item of the Component Gallery. This enhanced framework supports the framework available in Visual FoxPro 5.0 including the following:
The Visual FoxPro 6 framework uses an enhanced Application Object and provides the following additional elements:
You can start the Application Builder from the Visual FoxPro Tools menu or from the Component Gallery.
To start the Application Builder from the Tools menu
To start the Application Builder from the Component Gallery
When you choose OK, the builder closes, applying the property settings from all tabs.
You can also start the Application Builder with a right-click in the Project Manager window, but when opened this way, Application Builder creates only meta tables for your Application — you will see only three tabs in the Application Builder. The only way to provide the full Enhanced Application Framework to your application is through the Application Wizard or through the New Application item of the Component Gallery.
For details on the contents and use of the enhanced Application Framework and the Application Builder, see Developing Applications Using the Application Framework in Help.
Master Include File
This common #INCLUDE file is used by components with settings and strings. The file also includes the APP_GLOBAL value, the name used by components for referencing.
Configuration File
An optional Config.fpw used for applications such as top-level forms in order to implement settings such as SCREEN=OFF.
Project Hook Class
Controls events related to the project such as adding new files. It also can access Application Builder for setting actions and properties of file interaction within the application.
Application Meta Table
Contains information such as project settings made or used by the Application Builder and Project Hooks.
Application Builder
Facilitates adding components to the project and setting properties such as navigation options.
An application framework includes the project file and a starter class library subclassed from the Visual FoxPro base classes, ready for you to populate with new or existing tables and documents.
The framework allows you to specify whether to create a complete application or just an application framework. If you choose to create a complete application, you can either include in the application a database and forms or reports you have already created, or you can create a new application from scratch using a database template. If you choose to create a framework, you can go back later and add components to the framework.
You can create an Application Framework by using the Application Wizard or by using the New Application item in the Component Gallery. When you use the Component Gallery, a new project folder item is added to your Favorites folder.
Whichever method you use, Visual FoxPro displays an Application Builder so you can add information to be stored in a meta table.
To create an application
-or-
For details on the contents and use of the enhanced Application Framework and the Application Builder, see Developing Applications Using the Application Framework in Help.
You can also use the Component Gallery to add forms, reports, data, and service objects to your new application framework and controls to forms.
When you use the Component Gallery to add a form to an application, you can create a new form or subclass from an existing class.