Visual FoxPro 3.0 Reviewers Guide
January 1995

Table of Contents

Introduction
Welcome to Microsoft® Visual FoxPro™ version 3.0, the powerful new object-oriented environment for database construction and application development. Visual FoxPro 3.0 provides the tools users need to manage data -- whether they are organizing tables of information and running queries, creating an integrated relational database management system (DBMS), or programming a fully developed data-management application for end users.

This guide is designed to help you evaluate Microsoft Visual FoxPro version 3.0. The document highlights features that will help increase developer productivity, new client-server capabilities, and new features included in Visual FoxPro 3.0. If you are new to the Microsoft FoxPro database management system, this document also will introduce you to the strengths of Microsoft Visual FoxPro 3.0 as a complete PC database solution.

The two editions of the Microsoft® Visual FoxPro™ version 3.0 database management system (DBMS) for the Windows® operating system are designed to meet the distinct and overlapping needs of two varied groups of software developers -- professional developers and casual programmers. Offering two editions is consistent with the overall Microsoft mission in creating development tools, which is to design and provide a range of tools that meets the needs of diverse developers and applications, rather than forcing all developers to use one tool or methodology.

Design Goals for Visual FoxPro 3.0
Microsoft solicited extensive feedback from the database community on what should be included in Visual FoxPro 3.0. From the information gathered, the company decided to concentrate on the four major areas listed below.

Provide Rapid Application-Development Capabilities That Increase Developer Productivity
When developer productivity is discussed in this guide, it is referring to rapid application development (RAD). Visual FoxPro 3.0 allows users to build components (objects) that can be reused. The Xbase language in Visual FoxPro 3.0 has been extended to allow the creation of true objects, classes and subclasses. In addition, objects can be created visually and reused at any time. Visual FoxPro 3.0 has exposed the native event loop and evolved to comply with the Windows operating-system programming paradigm, allowing users to build event-driven applications.

Provide the Best Set of Tools for High-Performance Client-Server Development
Customers wanted Visual FoxPro 3.0 to be an excellent solution for client-server development. Microsoft has integrated the Visual FoxPro 3.0 Connectivity Kit, making client-server development possible in the standard product. Visual FoxPro 3.0 has been enhanced to be an excellent front-end tool for accessing back-end data. Through Open Database Connectivity (ODBC) technology, users can create connections to the back end that are stored in a database container. When the container is opened, the connection is made. Visual FoxPro gives users the ability to perform client-server protoyping locally using the Visual FoxPro 3.0 engine, then move the application seamlessly to a true client-server environment without changing a single line of code.

Integrate Visual FoxPro 3.0 With the Microsoft Family, Allowing for Development of Applications That Leverage Other Microsoft Products and Technologies
Visual FoxPro 3.0 interoperates well with other applications through OLE component software; interapplication application programming interfaces (APIs) such as the Messaging API (MAPI), and wizards, such as the PivotTable™ Wizard. Visual FoxPro 3.0 can host OLE Controls, giving users the ability to extend Visual FoxPro 3.0. Visual FoxPro 3.0 also can host OLE Automation server components such as Microsoft Excel spreadsheets or Word documents. This gives users the ability to integrate their applications with other products that support OLE Automation.

Provide a Scalable Migration Solution to Preserve Existing Investments in FoxPro 2.x
Another strength of Visual FoxPro 3.0 is its ability to protect customer investments by enabling them to use their legacy Xbase applications in Visual FoxPro 3.0. Microsoft's goal was to make Visual FoxPro 3.0 an object-oriented and modeless application-development tool while still allowing users to employ their existing applications. Visual FoxPro 3.0 runs FoxPro 2.x-based applications unchanged and provides a transporter that ports the applications to Visual FoxPro 3.0 automatically.

Provide Rapid Application-Development Capabilities That Increase Developer Productivity: A Closer Look
Rapid application development gives users the ability to build complex database applications visually with minimal effort. RAD is supported in Visual FoxPro 3.0 with a feature-rich object model that includes a complete set of base classes, inheritance, class definition, polymorphism and encapsulation. Consequently, users spend less time creating the building blocks, prototyping, and implementing the database application fully.

Object-Oriented Programming in Visual FoxPro 3.0
While Visual FoxPro 3.0 still supports standard Xbase procedural programming, new extensions to the language give users the power and flexibility of object-oriented programming.

Object-oriented design and object-oriented programming represent a change in focus from standard procedural programming. Instead of thinking about program flow from the first line of code, users need to think about creating objects -- self-contained components of an application that have private functionality as well as functionality that developers can expose to the user. Object-oriented programming models real-life objects with software counterparts, and it represents a more natural way for developers to think about the way they might want their applications to work. Classes and objects are two fundamental concepts of object-oriented programming. A class contains information about how an object should look and behave. In other words, a class is the blueprint of an object. Visual FoxPro 3.0 allows users to create objects visually and nonvisually. The following syntax is the basic shell for class creation:

DEFINE CLASS Classname1 AS cBaseClass
 [[PROTECTED PropertyName1,PropertyName2...]
    PropertyName = eExpression...]
 [[ADDD OBJECT [PROTECTED] ObjectName AS ClassName [NOINIT]
    [WITH cPropertylist]
 [[PROTECTED] FUNCTION/PROCEDURE Name
    cStatements
 [ENDFUNC/ENDPROC]]
ENDDEFINE

Visual FoxPro 3.0 also allows users to create classes and subclasses visually. The Visual Class Designer in Visual FoxPro 3.0 lets users create classes without having to learn the syntax for the new object model. Some of the features of the Visual FoxPro object model are outlined below.

Inheritance
Inheritance is one of the most powerful features of object-oriented programming. A newly created object can inherit characteristics (i.e., properties and methods) from its parent, often referred to as a "template." Although objects can inherit characteristics from their parents, they can also override the inheritance. Inheritance and overrides allow the user to eliminate the need for duplicate code when similar functionality is needed, but also provide the user with the flexibility to customize objects for specific use. Visual FoxPro 3.0 fully supports inheritance and overrides both syntactically through code and visually through the design interface.

Subclassing
Subclassing takes inheritance one step further by extending the feature to classes. Hence, not only can a newly created object inherit characteristics from its parent, but also a newly created class can inherit from a parent. In addition to the benefits of inheritance, the ability to subclass allows users to create libraries of reusable classes with very little or no new code. Furthermore, if a newer functionality is desired in all the derived children classes, the developer simply introduces the functionality once in the parent class, and all derived children classes will inherit the functionality automatically.

Encapsulation
Object-oriented programming also allows users to encapsulate attributes (properties) and behaviors (methods) into objects. In Visual FoxPro, users can package the information about the object so that access to the information is only possible via user-specified interfaces. This allows users to create "opaque boxes" that hide information. Even though the internal implementation and management of the object may be completely hidden, the object knows everything it needs to know in order to behave accordingly.

Polymorphism
Visual FoxPro 3.0 allows users to take advantage of polymorphism. Polymorphism is useful when a specific function must behave differently under various circumstances. For instance, an arbitrary DRAW method can be polymorphic, depending on the type of shape object (e.g., a square or circle) that has invoked the DRAW method. This dynamic binding of functionality allows users to create structured class hierarchies, where the basic skeletons of objects are defined in the base class, and specialized code is actually defined in the derived subclasses.

Event-Driven Application Development in Visual FoxPro 3.0
Traditionally, Xbase has required users to either write their own handler to process a limited set of events or to rely on READ, a wait state that simulates event handling by the system. With Windows, the number of events users may want to access is greatly increased and, consequently, event handling is more complex. While it is still possible for users to fully devise their own event-handling scheme or to rely on READ, Visual FoxPro 3.0 has evolved to become a true event-driven model, so that by default the system, rather than the users, handles object events. Furthermore, in Visual FoxPro 3.0, the user is now able to access fully the standard set of Windows-based events (e.g., mouse movements that enable the dragging and dropping of objects). Finally, the FoxPro language for accessing objects has been updated to the standard syntax of object.member (where member can be a property or event), which promotes consistency with other Windows-based event-driven development environments. The advances made to event handling combined with full support for object orientation make it easy to develop Windows-based applications using Visual FoxPro 3.0 and make Visual FoxPro 3.0 a powerful, first-class development tool for Windows.

Visual Design Tools
Microsoft has enhanced its award-winning set of design tools to allow visual application development. The visual design tools in Visual FoxPro 3.0 have been enhanced and offer more power than in previous versions. As mentioned above, one of the major advantages of Visual FoxPro 3.0 is the increased developer productivity it offers, which primarily results from designing applications visually. Some of the new and improved visual design tools included in Visual FoxPro 3.0 are as follows:

Project Manager
The FoxPro 2.6 catalog manager and project manager have been combined into a new Project Manager in Visual FoxPro 3.0. The new Project Manager is the central hub for application development and can be used to organize and manage files in projects. A project is a collection of files, data, documents and FoxPro objects that is saved as a file with a .PJX extension.

The items in the Project Manager are organized in an outline view that users can expand or collapse. A plus sign (+) appears next to a symbol if there are one or more items of that type in the project. Users can click the plus sign next to a symbol to expand the list to see its contents. This allows users to access all files associated with the project very quickly and easily without having to go to another area of Visual FoxPro 3.0. Multiple projects can be open at the same time in Visual FoxPro 3.0, and users can drag and drop files between open projects.

Users can dock the Project Manager, like toolbars, by dragging it to the top or bottom of the screen. When it is docked, it collapses automatically and shows only the tabs. This frees the desktop so it can be used for designing database applications.

The Project Manager window consists of six tabs: All, Data, Documents, Classes, Code and Other. The image below shows the Project Manager.

[vfp_rga  6844 bytes ]
Fig. 1. Project Manager Window

When the Project Manager is collapsed, users can tear off tabs by dragging them away from the Project Manager as seen in Fig. 2. Tear tabs allow users access to files on the desktop. Notice the push pin on the data tab. The push pin allows users to tack the tab to the desktop so that it is always on top of other windows being used. This gives users instant access to the files they use most often. For instant access to the files within each tab, Visual FoxPro 3.0 has full right-mouse-click support, providing menu options for the item selected. Full drag-and-drop capabilities exist from within the tabs, so users can simply drag and drop items such as fields directly onto their forms and reports -- allowing very easy application development.

[ Fig. 2.  Project Manager Tear Tabs ]
Fig. 2. Project Manager Tear Tabs

Database Designer
The Database Designer displays all tables, views and relationships contained in the database. When the Database Designer window is active, FoxPro displays the database menu on the menu bar and the database toolbar. The Database Designer allows users to create database schemes graphically by adding tables to the Database Designer, then relating those tables graphically by dragging and dropping related fields. The following is an image of a database schema created using the Visual FoxPro 3.0 Database Designer.

[ Fig. 3.  Database Designer ]
Fig. 3. Database Designer

The Database Container in Visual FoxPro 3.0 is a repository for all related tables, local views, remote views and connections. When a user creates a connection to back-end data, it is stored within the Database Container. When the user opens the Database Container, the connections that were created for that database are activated, as well as all of the views, remote views, stored procedures, tables and their relationships. When relationships are set within the Database Container, they are persistent throughout the entire application. This means that when multiple tables are used for forms and reports, the relationships between the tables are created automatically, based on the relationships created in the Database Designer. This is a much more efficient development environment and allows rapid application development.

Form Designer
Regardless of their complexity, nearly all database applications require the use of forms. As a result, the Form Designer is the most frequently used tool in developing an application. The new and much improved Form Designer in Visual FoxPro 3.0 contains features designed to increase ease of use and developer productivity. For example, users can align objects easily with the Layout toolbar, and they have fast access to the layout properties of an object using the tabbed Properties window. Visual FoxPro 3.0 has also made binding objects and data easy with the graphical Data Environment Designer. Complex data-management forms can be created easily in Visual FoxPro 3.0 by dragging and dropping fields and controls onto the form-design surface. The Form Designer also has been integrated tightly with the Visual FoxPro 3.0 object model. For instance, while designing a form, users can actually save a group of objects as a class from within the Form Designer. In addition, the Form Controls toolbar is context-sensitive, so users can populate the toolbar visually with a specific user-defined class library. Finally, all the advances in the Form Designer are also carried over to the Visual Class Designer. Consequently, users do not have to learn two different interfaces for building forms and classes, and training costs are reduced.

Below is an image showing the new Form Designer with the controls available for use on the form.

[vfp_rgd  17049 bytes ]

[ Fig. 4.  Form Designer ]
Fig. 4. Form Designer

The Form Designer has many toolbars to help users create forms. The Form Controls toolbar gives users access to the controls that are available in Visual FoxPro 3.0. The Color Palette toolbar gives users the ability to change the color of forms and controls. The Layout toolbar makes it easy to align and manipulate the locations of controls on a form.

Visual Class Designer
As mentioned previously, classes can be designed visually using the Visual Class Designer. The following is an image showing the Visual Class Designer.

[ Fig. 5. Visual Class Designer ]
Fig. 5. Visual Class Designer

The new object-oriented programming language extensions in Visual FoxPro 3.0 give users the ability to create classes through code. Visual FoxPro also includes the Visual Class Designer for creating classes. As you can see from the image above, the Visual Class Designer allows users to create their own properties and methods. Once a property or method has been defined, it appears on the property sheet. In the image above, a method and property were created called sample_method and sample_property.

Visual FoxPro 3.0 offers improvements to the controls included in FoxPro 2.6 and offers several new controls. One of the most powerful controls that is new to Visual FoxPro 3.0 is the Grid Control. The grid allows users to present and manipulate rows and columns of data in a form or page. The Grid Control contains cells, rows, columns and data that can all be manipulated through property settings. The grid also can be saved as an object for reuse in other forms. Because the grid can be placed directly on a form, creating One-To-Many forms is very easy. Users can create complex One-To-Many forms in much less time than in the past.

[ Grid Control ]
Fig. 6. Grid Control

Another powerful control that is new to Visual FoxPro 3.0 is the Page Frame Control. A page frame is a container object that contains pages. The Page Frame Control defines global characteristics of the form page, including border style, size and positioning, and it lists which page is active. A page frame contains pages, and pages contain controls. Much as a form can be thought of as a window on a plane that contains controls, the Page Frame Control can be thought of as a window on layered pages that contains controls. The page frame defines the location of the pages and the amount of information that is visible. Pages themselves have an infinite size. They always snap to the upper-left corner of the frame. As the frame is moved, the pages behind also are moved. Controls can be placed on pages outside the frame. These controls will be active but invisible. This control is extremely powerful because users can simulate many windows in one. Every window opened uses resources, so fewer resources will be used by placing more information in one window.

[ Fig. 7. Page Frame Control ]
Fig. 7. Page Frame Control

Provide the Best Set of Tools for High-Performance Client-Server Development: A Closer Look
Visual FoxPro 3.0 provides users the tools to create powerful client-server applications. A Visual FoxPro 3.0-based client-server application is an application that combines the power and graphical user interface of Visual FoxPro 3.0 with the speed, massive data storage and built-in security of an ODBC-based data source or server. This gives users of Visual FoxPro 3.0 the ability to create graphical client-server applications that provide maximum speed, security and power.

The first step in developing a Visual FoxPro 3.0-based client-server application is to build a prototype. A prototype is a completely functioning application that runs against either remote or local views. In either case, users typically limit the amount of data in the view to speed development. Visual FoxPro 3.0 allows users to move small data sets from a server with the use of views and, specifically, parameterized views. Parameterized views are one of the most important factors in building a fast, efficient client-server application because they allow users to minimize the amount of data that is pulled down from the server.

Visual FoxPro 3.0 allows users to build prototypes of their client-server applications using local data with local views. A local view uses local FoxPro tables rather than remote server tables. The local data, however, mimics the structure of the data on the server. Using local data to represent remote data also allows users to quickly develop and test the basic design of their application. By prototyping an application locally, perhaps module by module, users can discover changes and enhancements to their application's design early in the development process. The design can than be fine-tuned efficiently against small sample data stores before adding the additional layer of complexity inherent in working with remote, heterogeneous data.

The basics of creating views are the same as creating queries. The main differences are the update options provided on the Update Criteria tab of the View Designer. These options let users control how update requests are sent to the source tables.

Remote views are the same as local views except that they are based on remote data such as that held in a Microsoft SQL Server™ DBMS. They are created and designed with the View Designer in the same manner as local views.

[ Fig. 8.  View Designer ]
Fig. 8. View Designer

Creating a Connection
If users want to create a customized connection to a server, they can use the Connection Designer. The connection that is created is saved as part of the database and contains information about how to access a specific data source.

[ Fig. 9.  Connection Designer ]
Fig. 9. Connection Designer

The Data Processing options in the Connection Designer allow users to perform batch processing. This means that data can be moved to the front end from the back-end server and manipulated locally. When additions and/or modifications to the data have been made, the user sends the updated information back to the server. This greatly reduces the network traffic in client-server environments. When working in a multiuser environment, it is possible for several users to attempt to make changes to the records on the remote server simultaneously. Visual FoxPro 3.0 will inform users automatically if the information has been changed by another user when that data is sent back to the server.

Integrate Visual FoxPro 3.0 With the Microsoft Family, Allowing for Development of Applications That Leverage Other Microsoft Products and Technologies : A Closer Look

Interoperability and Extensibility
Visual FoxPro 3.0 interoperates well with other applications through OLE Automation and supporting interapplication APIs such as the Messaging and Telephony APIs (MAPI and TAPI). With interapplication wizards such as the PivotTable wizard and the Mail Merge wizard, developers can use Visual FoxPro 3.0 to interact easily with other applications. Futhermore, developers can use the OLE Automation capabilities in Visual FoxPro 3.0 to control other applications. A useful example of this is an executive information system (EIS) application, where a Visual FoxPro 3.0 form is the primary controller of Microsoft Excel and Word. Developers can use the Rushmore™ query optimizer to gather a resulting data set and send it off to Microsoft Excel for further analysis. And because OLE is integrated completely into the Visual FoxPro 3.0 object model, users can manipulate the Microsoft Excel or Word object in the same way they would a Visual FoxPro 3.0 object. All of this benefits users by allowing them to easily combine the best of Visual FoxPro with the features of other applications to meet complex business needs. Finally, Visual FoxPro supports OLE Controls. Users can purchase OLE Controls and use them to extend the funtionality of their applications. Moreover, users actually can extend the functionalities of OLE Controls in Visual FoxPro by subclassing the controls as they would a regular Visual FoxPro object. This allows for the maxium amount of flexiblity and extendability for users, and leverages fully the growing number of third-party vendors that are creating OLE Controls.

Provide a Scalable Migration Solution to Leverage Existing Investment in FoxPro 2.x: A Closer Look
Visual FoxPro 3.0 puts users in the driver's seat when it comes to leveraging their existing investment in FoxPro. Code can be migrated in three ways. Users can run FoxPro 2.x code unchanged, add object extensions to their code, or use the built-in converter in Visual FoxPro 3.0 that transforms FoxPro 2.x object files to the Visual FoxPro 3.0 format.

Visual FoxPro 3.0 allows users of FoxPro 2.x to run their code unchanged. Applications simply run as is, so users do not have to experience any downtime. Users can add object extensions to their .PRG or program files to tap into the new functionalities of Visual FoxPro 3.0 without conversion.

Finally, to upgrade an application fully and automatically, developers can use the Visual FoxPro 3.0 converter. The converter is a program included in Visual FoxPro 3.0 that converts FoxPro 2.x-based objects to Visual FoxPro 3.0 format. When users open an object file in Visual FoxPro 3.0 that was created with FoxPro 2.x, the converter automatically asks the user if conversion is desired.

Once object files have been converted to Visual FoxPro 3.0, they can be further enhanced to take full advantage of the entire feature set. The converter automatically creates a backup of all files that are converted, so users can always go back to the FoxPro 2.x versions of their applications.

Additional Product Enhancements

Local Data Dictionary
Today, users spend much time writing code to perform basic relational database functions. Microsoft has made enhancements to Visual FoxPro 3.0 to help increase developer productivity by having the system do more work with respect to data integrity, allowing users to concentrate on data management. Business rules, which are set at the table level, are enforced automatically when the table is used anywhere in the application. These enhancements address areas that currently take time and cause users grief.

Database Container
One major enhancement in Visual FoxPro 3.0 is the inclusion of the Database Container. In Visual FoxPro 3.0, users create databases to organize and relate tables. The database provides the architecture for storing data and brings additional benefits. With a database, users can create persistent relationships between tables, stored procedures, and many table-level extensions (such as field- and record-level rules and default field values), and they can create views of local and remote data.

Data Environment
The Data Environment Designer can be used to visually create and modify the data environment of forms, form sets and reports. A data environment defines the source for the data used in a form or report, including tables, views and relationships. The data environment is saved with the form or report and can be modified whenever the Report or Form Designer is used. When the data environment of a form or report is defined, Visual FoxPro 3.0 opens the tables or views when a user opens or runs the file, and it closes them when the file is closed or released.

Write an Application Once for FoxPro, and It Runs on all Windows Operating Systems
Visual FoxPro 3.0 was developed to run on Windows in a 16-bit or 32-bit environment. This means that the product can be installed on the Windows, Windows NT or Windows 95 operating systems. Applications written using one Windows operating system will run on any other Windows operating system. Note: Visual FoxPro 3.0 will take full advantage of Windows 95 when it ships later this year.

Wizards
Microsoft has added numerous wizards to Visual FoxPro 3.0 that help users create tables, forms, reports and queries, as well as interact with other Microsoft Office applications such as Word and Microsoft Excel. The following is a list of the wizards offered in Visual FoxPro 3.0:

Builders
A builder, such as the List Box Builder, is a FoxPro tool that helps the user set properties for a specific control or combine clauses to create a specific expression. A builder can consist of one or more dialog boxes that present a simple set of choices. Builders are programs in Visual FoxPro 3.0 that interact with a form or any of its controls while in the Form or Class Designer. Builders allow direct manipulation of properties and methods while in design mode. The general difference between wizards and builders is that wizards are designed to step users through a particular process quickly, whereas builders are used to edit methods and properties of "live" objects in the form and/or class design mode.

[ Fig. 10.  List Box Builder ]
Fig. 10. List Box Builder

Visual FoxPro 3.0 Performance
Visual FoxPro 3.0 will continue the performance tradition of the previous versions of FoxPro. FoxPro 2.6 was the fastest PC database management system on the market, and we expect Visual FoxPro 3.0 to continue to be a performance leader. The Rushmore query optimization technology allows Visual FoxPro 3.0 to handle large sets of data very easily. The end result is that Visual FoxPro 3.0 can help make users highly productive by giving them instant access to their data.

The Rushmore query optimizer, first introduced in FoxPro version 2.0, is included in Visual FoxPro 3.0. An exclusive technology for selecting sets of records from data tables rapidly, Rushmore can reduce response times for many queries to a matter of seconds rather than minutes or hours.

As a result of the optimized performance of Rushmore, applications that previously may have required a minicomputer can now run effectively in a PC environment using Visual FoxPro 3.0. With this kind of performance, Visual FoxPro 3.0 can be a cost-effective solution to large-scale data-management problems.

Test Drive of Microsoft Visual FoxPro 3.0
The purpose of this test drive is to highlight a few of the many new and powerful features of Visual FoxPro 3.0. The best way to understand Visual FoxPro 3.0 is to use the product. In this section, we'll take you on a tour of Visual FoxPro 3.0.

Let's start by double-clicking the Visual FoxPro 3.0 icon. When you launch the program, you'll see the Visual FoxPro 3.0 desktop and Project Manager (see Fig. 11).

[ Fig. 11. Visual FoxPro 3.0 Project Manager ]
Fig. 11. Visual FoxPro 3.0 Project Manager

Notice that when you first start Visual FoxPro 3.0, a project is opened automatically. Let's take a look at what's on the desktop.

Toolbar
Toolbars make it easy to perform many tasks in Visual FoxPro 3.0. All toolbars are customizable and dockable. By default, Visual FoxPro 3.0 shows the standard toolbar in most modes. Visual FoxPro 3.0 shows and hides other toolbars as appropriate. For example, the Query toolbar is displayed when a query is open. To display any toolbar at any time, choose the Toolbars command from the Tools menu.

Position the mouse pointer over any button to display its name in a ToolTip and its description in the status bar.

Command Window
The Command window is a Visual FoxPro 3.0 system window. When you choose options from the menu, you're actually generating Visual FoxPro 3.0 commands in the Command window.

Project Manager
The FoxPro 2.6 catalog manager and project manager have been combined into a new Project Manager in Visual FoxPro 3.0. You can use the Project Manager to organize and manage your files in projects. When the Project Manager window is active, Visual FoxPro 3.0 displays the Project menu on the menu bar.

Let's take a closer look at the Data tab in the Project Manager:

  1. Click the Data tab
  2. Click the + next to Database
  3. Click the + next to Tastrade
  4. Click the + next to Tables
  5. Click the + next to Customer
You can "drill down" to information within the Project Manager. In this case, we opened the database called Tastrade and drilled down through the tables contained within it. Notice that you can drill all the way down to the field level within the Customer Table.

The Project Manager can be seen in three different ways: maximized, which is demonstrated above; minimized, by clicking the up arrow on the top-right side of the Project Manager; or docked, by dragging the Project Manager to the top of the screen under the System toolbar. When the Project Manager is docked or in its minimized position, it takes on one additional characteristic. Dock to Project Manager, click the Data tab, and drag it down on the desktop. This is what we call Tear Tabs (see Fig. 12). Tear Tabs lets users take the information they use most, place it on the desktop, and have instant access at any time during development. Notice that the Data tab that is now on the desktop has a push pin. If you click the push pin, the tab will always appear on top of any other window. For example, click the push pin and try to move the command window over the Data tab. If you click the push pin again, the tab will now allow the command window to be placed on top.

[ Fig. 12.  Tear Tabs ]
Fig. 12. Tear Tabs

In Visual FoxPro 3.0, the tables are kept in a Database Container. Let's take a look at how we create and manipulate the Database Container. Click the Tastrade database in the Project Manager. Click the modify button.

[ Fig. 13.  Database Designer ]
Fig. 13. Database Designer

In Fig. 13, you can see the relationships that are present within the Tastrade database. This is the Visual FoxPro 3.0 Database Designer. Visual FoxPro 3.0 lets users design databases visually. Let's relate two of the tables together.

Click the customer table, scroll down to the cust_id index, and drag and drop that index onto the Orders customer_id index. Notice that the relationship builder appears automatically and allows you to change the relationship if you desire. Click the OK button. Now you have a persistent relationship between Customer and Orders. This is a One-To-Many relationship shown graphically.

Close the Database Designer by double-clicking the close box.

Let's now take a look at the Form Designer. Make sure that the Project Manager is docked at the top of the screen. Click the Documents tab and then click the word Form using the right mouse (notice that Visual FoxPro 3.0 has full right-mouse-click support). Select New and choose New Form. You will now be in the Form Designer, as shown in Fig. 14

[ Fig. 14.  Form Designer ]
Fig. 14. Form Designer

To activate the properties sheet for this form, simply right-click anywhere on the form and choose properties from the menu. To bring up the toolbars, click View from the main menu and select Toolbars. From the Toolbars window, choose Form Controls and Form Designer.

Let's create a simple form. Click the Data tab in the Project Manager and select the Tastrade database. Select the Customer table from within the database and drill down to the field level. Drag and drop company_name, contact_name, address, city, postal_code and phone on the form. Arrange the fields so they are aligned as shown in Fig. 15.

[ Fig. 15.  Simple Form Creation ]
Fig. 15. Simple Form Creation

Now select all of the fields (Edit/Select all), click the File menu, and select Save As Class. The Save Class window will appear. Make sure that Selected Controls is selected. Type in Cust_info for the Name, c:\vfp\sample\mainsamp\libs\tsbase.vcx for the File and click the OK button to save.

[ Fig. 16.  Save Class Window ]
Fig. 16. Save Class Window

Close this form by clicking File on the menu bar and selecting Close.

Choose No when the dialog box asks if you want to save changes.

Let's create a new form that uses the new Cust_info class. Click the Documents tab and right-click on Forms. The Form Designer is opened by choosing New and selecting New Form. Click the Classes tab in the Project Manager and drill down on the custdata library. Drag and drop the cust_info class on the form. Notice that you can drag and drop existing classes onto forms. Now go back to the Classes tab, select VCR, and drag and drop it onto the form below the orders grid. Your form should look similar to the one in Fig. 17. To run this form, you can simply click the [ System toolbar icon ]from the System toolbar. When Visual FoxPro 3.0 asks if you would like to save the form, click Yes and name the form Customer.

[ Fig. 17.  New Form Creation ]
Fig. 17. New Form Creation

Close this form by hitting the <Esc> key.

Now let's add additional functionality to this form by making it a One-To-Many form. In this case, we want to see the customer information as above and the corresponding orders that are related to each customer. Open the Customer form by going to the Documents tab in the Project Manager. Highlight Customer and right-mouse click. Choose Modify from the list. This takes you back to the Form Designer, where you can continue to enhance the Customer form.

Click the Data tab from the Project Manager and drag and drop the Orders table onto the form. Notice that Visual FoxPro creates a grid for you because you selected an entire table. Arrange the form so that it is similar to the one in Fig. 18.

[ Fig. 18.  Enhanced Customer Form  ]
Fig. 18. Enhanced Customer Form

You'll need to set a few properties for this form, and then you'll be done. Right-mouse click anywhere on the form and select Data Environment from the list. You will see the two tables used for this form -- Customer and Orders. Relationships need to be set for these two tables. Select the customer_id field from the Customer table and drag and drop it on the customer_id index of the Orders table. The relationship should look like the one in Fig. 19. Close the Data Environment window by double-clicking the close box. Click File from the menu bar, select Save As, type in Cust_Ord, and click the Save button. Now run this form by clicking the [ button ]button from the standard toolbar. Notice as you click through the records that the One-To-Many relationship between Customers and Orders is maintained.

[ Fig. 19.  Setting Properties in the Data Environment Window  ]
Fig. 19. Setting Properties in the Data Environment Window

Now let's go back and make a change to the class we created earlier. Click the Classes tab in the Project Manager. Drill down on Custdata by clicking the + sign. Highlight cust_info and
right-mouse click. Select Modify from the list and the Class Designer will appear. Let's change the background color of the class. Click View from the Menu bar and select Properties. Click BackColor in the property sheet and click the [ button ]button directly below the Other tab. This will bring up the color palette. Choose dark grey, then click the OK button. Your class should look like the one in Figure 20. Click back on the Class Designer, click File from the menu bar, and then choose close. When asked if you would like to save changes, choose Yes.

[ Fig. 20.  Making Changes to a Class Created Previously ]
Fig. 20. Making Changes to a Class Created Previously

Now open the Customer and Cust_Ord forms. Notice that the changes made to the class (background color) have been reflected in both forms. This is a simple example of inheritance, where the parent class is changed and all instances of that class are updated automatically. Figure 21 shows the Cust_Ord form with the class updated.

[ Figure 21.  Example of Inheritance ]
Figure 21. Example of Inheritance

Now let's take that same information and create a One-To-Many report using the Visual FoxPro 3.0 Report Wizard. Click Tools from the menu bar and select Wizards/Report. The Wizard Selection window will appear. Select One-To-Many Report Wizard and click OK.

Step 1: Fields From Main Table
Select Customer from the Table list. Add fields company_name and contact_name from the Available Fields list. Click the Next button.

[ Fig. 22.  One-To-Many Report Wizard -- Fields From Main Table ]
Fig. 22. One-To-Many Report Wizard -- Fields From Main Table

Step 2: Select Field From Child Table
The Report Wizard asks you to specify which table to use as the related table. Select Orders from the table list. Add Customer_id, Deliver_by, Discount, Employee_id and Freight from the Available Fields list. Click the Next button.

[ Fig. 23.  One-To-Many Report Wizard -- Child Table ]
Fig. 23. One-To-Many Report Wizard -- Child Table

Step 3: Key Fields
Visual FoxPro will suggest the relationship for the two tables automatically. In this case, the relationship is between Customer.customer_id and Orders.customer_id. Click the Next button.

[ Fig. 24.  One-To-Many Report Wizard -- Key Fields ]
Fig. 24. One-To-Many Report Wizard -- Key Fields

Step 4: Sort Order
The Report Wizard also lets you choose how the data will be sorted. Add Company_name as the sort order, and click the Next button.

[ Fig. 25.  One-To-Many Report Wizard -- Sort Order ]
Fig. 25. One-To-Many Report Wizard -- Sort Order

Step 5: Style and Layout
Select Columns from Field Layout and Portrait from Orientation. Leave Columns at 1 and Paper Size at Letter. Click the Next button.

[ Fig. 26.  One-To-Many Wizard -- Style and Layout ]
Fig. 26. One-To-Many Wizard -- Style and Layout

Step 6: Finish
The Report Wizard is now finished. Click the Preview button to see the results.

[ Fig. 27.  One-To-Many Report Wizard -- Finish ]
Fig. 27. One-To-Many Report Wizard -- Finish

Conclusion

We have just scratched the surface of this exciting new product. Visual FoxPro 3.0 is a full-featured database-development tool that allows rapid application development along with full client-server capabilities. Visual FoxPro 3.0 has complete migration capabilities that allow users to continue to use their existing Xbase applications. Microsoft believes Visual FoxPro 3.0 will continue to be a performance leader.


Professional Edition


Introduction: Visual FoxPro 3.0 for Windows Professional Edition

Summary of Enhanced Professional Edition Features at a Glance

Go here to find out why the Visual FoxPro Professional Edition is a more appropriate product offering to developers than the Standard Edition.

OLE Controls

OLE Controls allow users to add OLE objects to applications. OLE objects include OLE Controls (.OCX files) and insertable OLE objects from other applications such as Microsoft Word and Microsoft Excel. (For a list of insertable objects, refer to the Options dialog and select the Controls tab.) The Professional Edition ships with four additional development-focused OLE Controls designed to simplify the process of building robust Visual FoxPro-based solutions. They include MSCOMM32.OCX, MSMAPI32.OCX, MSOUTL32.OCX and PICCLIP32.OCX.

MSCOMM32.OCX
MSCOMM32.OCX is a Communications Control that provides serial communications for applications by allowing the transmission and reception of data through a serial port.

The Communications Control provides the following two ways of handling communications:

Each Communications Control you use corresponds to one serial port. If you need to access more than one serial port in your application, you must use more than one Communications Control. The port address and interrupt address can be changed from the Windows Control Panel.
MSMAPI32.OCX
The MAPI Custom Controls allow developers to create a mail-enabled Visual FoxPro solution. There are two MAPI controls -- MAPI session and MAPI messages.

The MAPI Session Control establishes a MAPI session, and the MAPI Messages Control allows the user to perform a variety of messaging system functions. The MAPI Controls are invisible at run time. In addition, there are no events for the controls. To use them, you must specify the appropriate methods.

MSOUTL32.OCX
The Outline Control, MSOUTL32.OCX, is a special type of list box that allows users to display items in a list hierarchically. This is useful for showing directories and files in a file system, which is the technique used by the Windows File Manager. Following is an image of the Outline Control to better illustrate its functionality:

[VFPPR86C  2442 bytes ]

PICCLIP32.OCX
Picture Clip Controls, PICCLP32.OCX, allow you to select an area of a source bitmap and then display the image of that area in a form or picture box. Picture Clip Controls are invisible at run time.

Picture clips provide an efficient mechanism for storing multiple picture resources. Instead of using multiple bitmaps or icons, you can create a source bitmap that contains all the icon images required by your application. When you need to access an individual icon, use picture clip to select the region in the source bitmap that contains that icon. For example, you could use this control to store all the images needed to display a toolbar for your application. It is much more memory-efficient to store all of the toolbar images in a single Picture Clip Control than it is to store each im age in a separate picture box.

The Icon Editor and the Library of Hundreds of Additional Graphics Files

In the extensive research Microsoft conducted with developers to design the Professional Edition contents, one of the most commonly requested features was pre-existing graphics libraries that could easily be modified for use in Visual FoxPro-based solutions. Therefore, Microsoft has included literally hundreds of graphic images in Visual FoxPro 3.0 that can be edited for use on icons or cursors, or as general bitmaps. To simplify the process of editing, Visual FoxPro Professional Edition includes an icon editor, Imagedit, and HotSpot Editor that can be used to modify images even to the pixel level.

The Class Browser

The Class Browser is a must for developers who create, manipulate and reuse classes within an application. The Class Browser gives users the ability to browse class libraries, which provides for easy application design and managing application components.

The Class Browser allows developers to trace class hierarchy in their solutions. The Class Browser can be used to view, use and manage classes and their user-defined members.

Browsing class libraries allows you to design and manage application components easily. The Class Browser shows you the interrelationship between classes in a visual class library (.VCX ) file. The Class Browser is written entirely in FoxPro and can be used to open single or multiple visual class libraries or form files (.SCXs) with the purpose of subclassing a new class, or redefining, removing or renaming a class. You can create new applications in FoxPro using the Class Browser by just dragging and dropping already-created classes into a form, therefore reusing your class library without writing any code.

One of the most important functions of the Class Browser is its ability to display the actual code behind classes in a visual class library. The developer can leverage this capability to learn object syntax by studying this code, and can make changes to the code based on his/her development objectives. To execute this feature, simply click the third displayed icon in the browser.

[VFPPR86D  10272 bytes ]

Use the Class Browser to do the following:

Additional Development-Oriented Wizards

Setup Wizard
The Setup Wizard is a must for developers who want to distribute their solutions to multiple end users. This wizard can create a setup routine for an application over a network or can create a set of disk image directories containing all the files needed to install an application. Visual FoxPro Professional Edition provides a distributable file that can be installed to leverage all Windows operating systems, including Windows 3.x, Windows 95 and Windows NT.

Developers who build and distribute applications through the Setup Wizard can choose to distribute ODBC drivers and Microsoft Graph applications and can automatically register OLE files if the files are included with their solution.

The Setup Wizard performs the following steps:

Upsizing Wizard to Microsoft SQL Server Back Ends
The Upsizing Tools built into the Professional Edition of Visual FoxPro allow users to create solutions in Visual FoxPro 3.0 and "upsize" them to run on Microsoft SQL Server™ back ends. Visual FoxPro 3.0 provides a complete client-server development path from the desktop to the server.

The Upsizing Wizard completely automates the process of upsizing data from Visual FoxPro to Microsoft SQL Server. The wizard preserves the database structure, including data, indexes and defaults. It also automatically converts the Visual FoxPro validation rules to Microsoft SQL Server equivalents. In addition, all of the relationships and referential integrity are maintained after upsizing.

Following are graphical representations of the steps that the wizard takes users through to upsize data:

[VFPPR86E  7217 bytes ]

In Step 8, the user is asked to specify which upsizing options they want to use. The user can choose to upsize existing Visual FoxPro indexes, default values, relationships and validation rules. Users also have the ability to upsize the physical structure of Visual FoxPro tables without upsizing the data associated with them.

The Upsizing Wizard also will make changes to the local Visual FoxPro environment. Views that were used on local data can automatically be redirected to view on Microsoft SQL Server. The wizard also will create an upsizing report to inform users about exactly what has happened in the upsizing process.

[VFPPR86K  8252 bytes ]

The final screen asks the user whether he or she wants to proceed with the upsizing process. The wizard also can display a Microsoft SQL Server script that users can see before the upsizing process. This allows users to change the Microsoft SQL Server script if they have specific functionality in the script that the Upsizing Wizard does not provide.

Creating Standalone Executables

Once a Visual FoxPro-based application is complete, the developer may wish to create an .EXE file that can be distributed to other developers or end users. The Professional Edition of Visual FoxPro allows developers to create executable files that are royalty-free and unlimited in terms of distribution. The executable can run on any PC that meets the system requirements for Visual FoxPro, and Visual FoxPro does not have to be installed on the run-time machine.

The FoxPro Library API

The Professional Edition also contains the full API for Visual FoxPro. This enables developers to extend the native functions and capabilities of FoxPro by creating function libraries with the Library API. Because Visual FoxPro is a 32-bit development tool, libraries constructed to access its APIs must be built with a 32-bit compiler. Therefore, the Professional Edition ships with a coupon that allows users to obtain the Microsoft Visual C++™ development system and/or Windows NT Workstation at the products' upgrade prices.

The Online Win32 Programmers Reference (CD-ROM Version Only)

The CD-ROM version of Visual FoxPro, Professional Edition contains an online, character-searchable version of the Win32 programmers' reference. The Microsoft Win32 API allows applications to exploit the power of 32 bits on the Windows family of operating systems. The Win32 functions, messages and structures form a consistent and uniform API for all Microsoft 32-bit platforms, including Windows 95, Windows NT 3.1 and Windows 3.1 with the Win32s® API. Using the Win32 API, you can develop applications that run successfully on all platforms while still being able to take advantage of unique features and capabilities of any given platform.

The Win32 API consists of these general functional categories:

With a few minor exceptions, Microsoft ensures consistent and uniform behavior of the Win32 APIs across all platforms. Differences in the implementation of the Win32 API depend on the capabilities of the underlying features of the platform. The most notable difference is that some Win32 APIs carry out their tasks only on the more powerful platforms. For example, security functions are available only on the Windows NT operating system. Most other differences are system limitations, such as restrictions on the range of values or the number of items a given function can manage.

Creating Graphical Help Systems

Visual FoxPro Professional Edition also allows developers to create customized Help systems that can be compiled and distributed with their solutions. These Help systems can have some or all of the following features:

Additional Training Options for Professional Edition Developers

"Mastering Microsoft Visual FoxPro"

Based on customer demand and training-industry trends, Microsoft has also developed a CD-ROM-based training product, available separately for professional database developers. "Mastering Microsoft Visual FoxPro" is a comprehensive tool designed to help experienced developers master Visual FoxPro. The product is aimed at an intermediate to advanced experience level.

A developer learns a new tool by using it. "Mastering Microsoft Visual FoxPro" follows the "learning by doing" approach, with task-based lessons, reference material, sample code and labs. Developers also want quick access to specific information. Based on customer feedback, the top design priority of "Mastering Microsoft Visual FoxPro" was a flexible browse-and-search system.

Easy, variable access to information is generally not a priority in CD-ROM-based training (CBT) design. Instead, users are subject to a "page-turning" approach, a linear paradigm in which users must complete progressive lessons in a course to learn a product. "Mastering Microsoft Visual FoxPro" unleashes developers from that traditional CBT approach and meets the need for maximum flexibility, through a feature called the Navigator.

Using the Navigator, developers can access task-based information through several contexts, including the following:

Following is an image of the Mastering Visual FoxPro Navigator to illustrate its capabilities:

For fast, targeted access to information, "Mastering Microsoft Visual FoxPro" includes a key word index and a full-text Boolean search engine. These search options enable developers to quickly gather the information needed to complete a particular development task.

Summary

The Professional Edition of Visual FoxPro provides the muscle that serious developers need. It includes an additional wealth of tools, components and information that broaden the range of database application creation possible and help the developer distribute solutions on a large scale. Visual FoxPro Professional Edition also has a CD-ROM-based training title, "Mastering Visual FoxPro" -- available separately -- designed specifically for the needs of professional Xbase developers. The future of Xbase development never looked so bright.

Remember, the Professional Edition of Visual FoxPro is the only Xbase development tool easy enough to be Visual, yet powerful enough to be FoxPro!


Microsoft, the FoxPro logo, Visual FoxPro, Windows, FoxPro, Windows NT, Win32, Visual C++ and Win32s are either registered trademarks or trademarks of Microsoft Corp. in the United States and/or other countries.

ORACLE is a registered trademark and ORACLE7 is a trademark of Oracle Corp.

Btrieve is a registered trademark of Btrieve Technologies Inc.

dBASE is a registered trademark and Paradox is a trademark of Borland International Inc.


© 1997 Microsoft Corporation. All rights reserved.