Visual foxpro programming lessons. How to close the viewport
It is an application that is an object-oriented and visually programmable language. Visual FoxPro fully complies with the new requirements for modern design and development tools software... Users of any skill level can use the Visual FoxPro language, and if you just start learning, you can use the wizards for creating databases, applications, tables, forms and reports.
In addition, this language will help you to quickly create and more complex programs or applications using constructors and an object-oriented language, using not only the base Visual FoxPro classes, but also external libraries. This collection will be useful both for a simple acquaintance with the capabilities of Visual FoxPro 8.0, and for completing a complete training course for working with the system. In addition, it contains many useful topics and more experienced users... For the convenience of studying the material, this application is made with illustrations in the form of help, which allows for easy navigation and find the necessary sections with descriptions.
Features Tutorial for Visual FoxPro:
- the opportunity to get acquainted with the capabilities of Visual FoxPro 8.0 or complete a complete training course for working with the system.
Advantages:
- the ability to view high-quality submitted material, made with illustrations in the form of help, which allows for easy navigation and find the necessary sections with a description.
See also programs:
Official source | ||
For OS | Windows XP, 98, ME, 2000, 2003 | |
Distribution size | 4.54 Mb | |
Interface language | Russian | |
Program | Free of charge | |
Updated | 2012/07/27 | |
Latest version | 8 |
Quick start is short description fundamental principles of working in a programming environment FoxPro for Windows version 2.5, was created so that you can get acquainted with the capabilities and organization of the system with the least amount of time. This guide is not full description and contains only the basic principles and points of working with databases. This description designed for beginners - users who first encountered FoxPro and do not know which side to approach it. Here you will find a description of the basic rules for viewing, creating and editing DBF databases, get basic skills in the programming environment FoxPro 2.5 for Windows
Note that when using FoxPro all the necessary information is always "at hand". FoxPro provides context sensitive help so that you can always get information about any system window, dialog, or menu command as you use it. For help, just press the F1 key.
Now, let's start with the simplest.
Chapter 1. Opening and viewing a table (DBF file).
This chapter describes how you can view an already created database.
A table is a file that contains ordered information. These files are sometimes referred to as .DBF files because they have the .DBF extension.
FoxPro contains a very powerful tool for viewing and editing table information. To get acquainted with these possibilities, we will use the already created table: CUSTOMER.DBF, which contains information about customers.
How to open and view a table
Place the cursor in the command window by clicking in it. Type set default to c: \ foxpro \ tutorial and press ENTER.
From the File menu, choose the Open command. The "Open" dialog will appear. Make the TUTORIAL directory active. From the Type list, select Table / DBF. And, having selected the CUSTOMER.DBF file, click the "Open" button.
Figure 1.1 Opening a table
This table is now active and to view it in the "Base" menu, select the "View" command. A preview window will appear. The information in the viewport is presented in rows and columns. Columns are called fields, rows are records. The viewport is usually not large enough to allow you to see the entire table at once. In order to see the different parts of the table, you need to scroll the viewport horizontally and vertically.
In the viewport, you can control the display of data on the screen, for example, you can change the width of individual fields.
How to change the width of the field
Move the cursor between the COMPANY field heading and the CONTACT field heading. This line is called the header separator. When you hit the title separator, the mouse pointer changes its appearance. And now, by clicking the mouse, set the required field size.
How to move a field
Point with the mouse to the heading of the CNO field. And by clicking the mouse button, move the title until it is between COMPANY and CONTACT.
Figure 1.2 Moving a title in a table
You can see all the fields at the same time by switching to the record view. In this mode, the fields of each record are arranged one below the other.
How to view data in record view mode
From the View menu, choose By Records. The view mode will change.
Fig. 1.3 View by records
Another way to view the data is to split the viewport into two sections using the split marker — the black rectangle in the lower-left corner of the viewport.
How to split the viewport
Place the mouse over the split marker. The mouse pointer changes. Move the window break marker behind the CONTACT field.
Splitting the viewport allows you to:
scroll through fields in one section without moving fields in another;
work with one section in the view by records mode, and with another in the tabular view mode.
How to select a section and change its mode
Select the right section by hovering over it and clicking. From the View menu, choose By Records.
Figure 1.4 Selecting a Partition
Since the sections are linked, scrolling will highlight the same entry for both sections. You can unlink sections and scroll through the entries in one section while leaving the entries in the other section unchanged.
Unlinking sections
From the View menu, choose Link Sections. The marker next to the Link Sections command disappears. Scroll through a few entries.
How to close the viewport
The window is closed as standard for WINDOWS systems, double-click the viewport control menu button, or press CTRL + F4.
Working with the Memo window
Now let's open another table containing information about sellers who participated in some commercial transactions, this is the file: SALESMAN.DBF
This table defines a NOTES field between the ONO and NAME fields and contains the words Memo or memo. This field is of a special type; it can contain an unlimited amount of any information. Since the amount of information can be very large, it is difficult to display it in a small area. To view and edit this information, use the memo-field editing window.
By looking at a memo field, you can immediately tell from the first letter of the word memo whether the field contains information or not. An uppercase "M" indicates that the memo field contains information, and a lowercase "m" indicates that the field is empty.
How to view memo field data
Open the memo field edit window. To do this, double-click on the word Memo.
Figure 1.5 Viewing Memo Field Data
In the window for editing a memo-field, you can not only view it, but also edit it. To close the memo field viewer, double-click the viewer control menu button.
Chapter 2. Data management.
In the previous chapter, you learned how to view information in a table. But what if it turns out that you need to view information of a given type? For example, you might want to know everything about customers who spent over $ 5,000 or just the name and number of each customer. FoxPro allows you to quickly retrieve and view information that meets specified conditions. The process of retrieving this information is called a "request".
How to open a query window
From the File menu select the Open command and in the FOXPROW \ TUTORIAL \ directory select the CUSTOMER.DBF file and click the Open button. Then, from the "File" menu, select the "New" command. In the "Create File" dialog, set the "Request" option, and then click the "Create" button. A request window will appear.
Rice. 2.1. How to open a query window
The query window specifies the information to be retrieved from the tables. The extracted information is placed in the viewport. You can work with this window as it was done in the previous chapter.
The Result Fields list in the query window specifies which fields you want to display in the browser. By default, all fields are displayed in a newly opened table.
The Selection Criteria area specifies which records you want to retrieve from the table. If the area is empty, the query retrieves all records from the table.
Let's say you don't need to view the CNO, ADDRESS, ZIP and ONO fields. Then we need to specify only those fields that are needed.
How to set fields for the query result
In the query window, select the Fields check box. The Select Query Fields dialog will appear.
Rice. 2.2 Setting the fields for the request
Click the Delete All button to clear the Selected Fields list. And put COMPANY, CNO, CONTACT, PHONE, CITY, STATE and YTDPURCH in the "Selected fields" list, for this select the required field in the "Table Fields" list and click the "Add" button. Each of the above fields will appear on the screen with the CUSTOMER prefix, which means that the field belongs to the CUSTOMER table. When finished, click the "Ok" button. The selected fields will appear in the Result Fields list in the query window. When you run a query, the fields in the viewport appear in the order specified in the query window.
How to fulfill a request
In the request window, click the "Run" button. And you will have a browser with the selected fields.
Rice. 2.3 Executing a request
If in the process of working with the viewing window it turns out that there is no longer a need for the CONTACT field, then simply remove it from the request.
How to remove a result field from a query
Close the browser displaying the query result. Check the "Fields" box. Remove the CONTACT field from the Selected Fields list by highlighting it in the list and clicking the Delete button. Click the "Ok" button. Note that the CONTACT field is no longer listed in the Result Fields list. And execute the request.
Now that the result fields are selected, you can set the order in which the data will be presented. For example, you can display data by city in alphabetical order.
How to arrange fields in a request
Close the browser with the displayed query result. In the query window, select the Order check box. In the "Order of query fields" dialog, place CUSTOMER.SITY in the "Order criterion" list. To do this, select it and click the "Add" button. And check the "Ascending" box.
Rice. 2.4 How to arrange fields in a request
To return to the request window, click the "OK" button. Notice that 1 and an up arrow appear next to CITY in the Result Fields list. The number 1 means that CITY has the first priority when ordering the data, and an up arrow means that the data is displayed in ascending order.
Click the Run button. The data can be ordered in any way. For example, you can sort data by state and by city within a state.
How to order by multiple fields
Close the viewport. Check the "Order" box. Place CUSTOMER.STATE in the Order Criterion list. Set the order of the fields, for this move the button to the left of STATE with the mouse so that the STATE field is above the CITY field. Click the "Ok" button. Now STATE is preceded by the number 1, and before CITY - 2, which means the priority for data ordering. And click the "Run" button.
So far, all records have been looked up in the CUSTOMER table. But suppose you want to view only those companies that are located in Ohio. Using the Criteria area of the query window, you can execute such a query almost immediately.
Setting selection conditions
To retrieve only the specified records, you must specify the selection conditions. Each selection condition consists of a table field, a comparison option, and a value to be compared with the field's contents.
How to set the selection conditions.
Close the viewport. In the query window, click the box below Field Name to display the Field Name list. Highlight CUSTOMER.STATE
Rice. 2.5 How to set selection conditions
In the list of comparison options, the default is "like". Type OH (Ohio) in the text box below Sample. This creates a selection condition to view records only for Ohio companies. In the same way, you can set several selection conditions. The introduced selection condition requires that the STATE field be similar to OH. STATE is a field, "like" is a comparison option, and OH is the value to compare the contents of the field to. The "like" comparison indicates that the STATE field must be OH in order for the record to satisfy the request. The result of executing the query is shown in
Rice. 2.6 Result of query execution
Other options for selection conditions
Let's try to withdraw companies located in Ohio or Michigan. Close the viewport. Click on the comparison options entry field and select the value "from the list". In the Sample field, type MI (Michigan) after OH. Don't forget to include a comma.
Rice. 2.7 Comparison option: "in the list"
Click the Run button. A browser will appear showing all companies located in Ohio and Michigan, because "listed" means that STATE must contain one of the items specified in the Sample text box to be included in the result.
Other selection conditions: equal, more, less, within; work in the same way. For more detailed information, refer to the reference: "User's Guide. FoxPro. Relational Database Management System for Windows".
Chapter 3. Working with the table.
This chapter describes how to create your own user table and how to add, delete, and modify entries in it.
Creation of the table structure.
First, decide what information should be put into the table.
Surname, name, patronymic of the employee;
Date of Birth;
Profession;
Wage;
A comment;
Each of the listed values will be stored in the corresponding field of the table.
How to create a table structure
From the File menu, choose New. The "Create File" dialog will appear. Select the "Table / DBF" option and then click the "New" button. The "Table Structure" dialog will appear
Rice. 3.1 Creating a table structure
The cursor is in the Name text box. Now you can add the name, type and width of each field.
How to describe table fields
Type "name" in the "Name" text box. Press Tab or click in the Type list. Set the type to "Character". Press the Tab key or click on the "Width" field, then type 25 or use the arrows to increase the width to 25. Next, describe the rest of the fields. The result is shown in
Rice. 3.2 Description of table fields
The Des field indicates the number of decimal places in the numeric field. Since the "salary" field stores the value of the monetary amount, you must specify the number 2.
After entering all the values, press the "Ok" button. The "Save As" dialog will appear. Enter the name of the table: TEST, if necessary, specify in which directory it should be written and click the "Save" button. FoxPro then asks, "Do you want to enter data records now?" Click the "Yes" button.
Entering data into a table
A view window will appear in edit mode by records. Add the following data to the table:
Ivanov Sergey Nikolaevich
accountant
Press CTRL + PGDN or double-click the memo field to enter information in the memo field. A memo window appears in which you can enter your comments.
Rice. 3.3 Entering Comments in the Memo Window
Close the memo window. Note that the letter "M" in the word Memo is uppercase, which means that the data in the field has already been entered. Add a few more employees and close the viewport.
Now, suppose you have purchased a scanner and want to add photographs of your employees to the table.
How to change the structure of a table
From the Base menu, select the Customize command. In the upper left corner of the "Database settings" dialog, click the "Modify" button. The "Table structure" dialog will appear. Move the cursor to the "comment" field and click the "Insert" button. New_field appears above the comment field. Replace "new_field" with "photo". In the "Type" list, select "General", and then click the "Ok" button. When prompted by FoxPro if you want to save your changes, click Yes. In the "Database settings" dialog press the "Ok" button.
Entering graphic data into the table
First of all, you need to add a photo of the employee to the clipboard.
From the Record menu, choose the Edit command. The mode of modification by records is set in the viewing window. Double click on the "photo" field. A window for editing a field of the General type will appear. From the Edit menu, choose Paste. The picture contained in the clipboard will appear in the window.
Rice. 3.4 Writing an image to a table
How to add new entries
From the Record menu, choose the Add command. A browse window will appear in the add mode, where you can add new employees.
How to delete an entry
In the table view mode, mark the fields for deletion. To do this, to the left of the field, click the delete marker.
Rice. 3.5 Deleting an entry
How to package a table
From the Base menu, choose the Pack command. A message appears asking if you want to package the table. Click the "Yes" button. Now choose View from the Base menu and make sure that all selected entries have been deleted.
Chapter 4. Generating reports
This chapter describes how to use the Query Box to quickly generate reports from your data.
Chapter 2 talked about displaying information in a viewport using a query. Another way of presenting information is a report.
A query is required to generate a report. We'll use the query created in chapter two.
How to open a request
From the File menu, choose the Open command. In the "Open" dialog that appears, select the TUTORIAL directory. In the Type list, select Request. Select the file you want (GSCHAP5.QPR) and click Open.
As the first report, let's make a list phone numbers all customers from California.
Generate a telephone list report as shown in Figure 4.1.
Rice. 4.1 Generating a Phone List Report
Include the following fields: COMPANY, PHONE, CONTACT, CITY, and STATE. Selection criterion: STATE is similar to CA. And most importantly, in the "Output" list, select the "Report / Label" value. Click the Run button.
The report starts scrolling on the screen.
After viewing the report, press ESC.
The above report contains the correct information, but its clarity can be improved.
How to create a report form
Check the "Options" box. In the "Query input parameters" dialog, select the "Report" option, check the "Standard report" checkbox, and in the "Standard query report" dialog in the "Save as" field, type the name gschap6.frx.
Rice. 4.3 Formation of the report form
Click the "Ok" button and the "Run" button.
The complete image of the entire page of the report can be seen in the "Page View" window, as shown in Figure 4.4.
Rice. 4.4 Image of the report page
The image of the report page gives an idea of how the report will look on paper.
In the "Page View" window, you can enlarge the image (the Zoom in button), you can zoom out (the Zoom out button), view the next or previous page (the Forward / Back buttons). Click "OK" to exit.
Now let's look at the created report form and make some improvements to it in the report layout window.
How to open a report form
From the File menu, choose the Open command. In the "Type" list, select the "Report" value, and open the file: GSCHAP6.FRX.
In the report markup window, the GSCHAP6 report form will appear, shown in Figure 4.5.
Rice. 4.5 Report Form
The report form is divided into three bands:
The Header strip contains information that appears at the top of each page in the report.
The Details bar is printed once for each entry that meets the selection criteria.
The Footer bar contains information that is displayed at the bottom of each page in the report.
Using the set of icons on the left side of the markup window, you can make the necessary changes to the report. For example, Figure 4.6 shows the layout of the report with the changes made.
Rice. 4.6 Making changes to the report
How to fulfill a request
Minimize the report window. Click the Run button. Please note that the report contains the changes made.
Rice. 4.7 Final report
And you can print this report on a printer.
Conclusion
We examined the basic possibilities of working with databases in the FoxPro environment, this is not limited to its capabilities, but for further work you need to have at least basic knowledge of the FoxPro programming language. If you decide to continue your acquaintance with the possibilities of using FoxPro, or if you have any difficulties, it is advisable to use the reference "Microsoft FoxPro for Windows", which you will receive along with the FoxPro software package.
Let's briefly consider other main features of working with databases:
Screen creation.
The FoxPro system is used to view data in a variety of ways. You can view the data table in the viewport, you can view the fields of each record, and using "screen creation" you can create your own method for viewing / modifying data by placing data in the desired places on the screen or pages. FoxPro's capabilities in this regard are simply unique.
Menu creation.
In a matter of minutes, you can create your own menu system, with all the necessary commands to work with your databases, and not use standard system FoxPro menu.
Project creation.
All elements: screens, reports, queries, menus ... can be combined into a single unit called a project.
The project is used to manage elements in the process of creating an application. Having created a project and specifying the files that should be included in it, you can use this project to build an application (.APP) or an executable file (if you have a FoxPro Distribution Kit)
Ok. In the dialog comment src = h4 style = m. Click the button
You are getting started with Visual FoxPro 8.0. Many of the things you will have to work with (menus, toolbars, dialog boxes) will seem familiar because they are specific to the Windows environment. | To run the program from the main windows menu follow these steps:
Visual FoxPro Main Window
In fig. 2.2 shows the main window of Visual FoxPro, as it looks after the launch of the program. | It has seven main objects: the window title, menu bar, toolbar, status bar, work area, Command window, and the Task Pane Manager dialog box.
System menu and system buttons
The title of the main window contains a small copy of the program icon, the text "Microsoft Visual FoxPro" and buttons to control the size of the main window. When you click on the icon of the icon, a system menu opens, containing commands for moving and resizing the main window. Table
Introduction to the Standard Visual FoxPro Toolbar
Visual FoxPro has a large number of toolbars used to create forms, reports, and queries. We will consider them in detail in the corresponding chapters. Now you will get acquainted with the standard toolbar (Fig. 2.3), which is used in all modes of operation. | Rice. 2.3.
A quick tour of the Visual FoxPro menus
When working with Visual FoxPro, you can use both the toolbar buttons and the menu bar, all of which are hierarchical commands. When you select a specific command, its submenu opens.
Exiting Visual FoxPro
To exit Visual FoxPro, you need to Close it. To do this, use one of the following methods: | select the Exit command from the File menu; | select Close in system menu main window of Visual FoxPro;
Taskbar manager
Visual FoxPro 8.0 includes a task manager to help you develop your application. The links in its window allow you to launch the New Application and Database Wizard, open the Help system, open the recently opened application or database, and much more.
Visual FoxPro Help
When developing applications in Visual FoxPro, as in any other system, it is often necessary to review the capabilities of programming tools, individual commands and functions. In Visual FoxPro, in addition to the traditional help system, you can find the information we are interested in in the built-in documentation, numerous examples, and on the Web pages.
Help window
In fig. Figure 2.11 shows the Visual FoxPro help window that opens when you select the Microsoft Visual FoxPro Help command from the Help menu. | This window is divided into two areas.
Using the Contents Tab
The first tab in the Help window is the Contents tab (see Figure 2.11). This tab takes the most traditional approach to getting help information. | The first time you open the Contents tab, you see a list of Help topics.
Finding Help by Subject Index
To search for help on a subject index, open the Index tab (Fig. 2.13) of the help system window. At the top of the tab there is a field for entering a keyword by which the search will be carried out.
Using the Search tab
To search by keywords and phrases use the Search tab. In the Search for next words input box, enter the word or phrase you want to search for. If you want to find a phrase, you must enclose it in single or double quotes.
Favorites tab
The Favorites tab (Fig. 2.16) allows you to create a list of the most frequently used topics in the help system, the selection of which should be done quite simply. | By default, this tab is empty. To add a help topic to the Favorites tab, you need to do the following:
Viewing online help information
The Visual FoxPro Help System contains a wealth of information needed to develop applications. To receive latest news About Visual FoxPro, you can open the corresponding Web page directly from the main Visual FoxPro window.
Lyudmila Omelchenko Daria Shevyakova SELF-TEACHER St. Petersburg "BHV-Petersburg" 2005 UDC 681.3.068 + 800.92 Visual FoxPro 9 LBC 32.973.26-018.1 O-57 Omelchenko L. N., Shevyakova D. A. O-57 Self-instruction manual Visual FoxPro 9.0 ... - SPb .: BHV-Petersburg, 2005 .-- 608 p .: ill. ISBN 5-94157-632-3 Considered Visual FoxPro 9.0 - a powerful software package designed to build professional database applications. An integrated application development environment and the creation of basic objects such as classes, tables, queries, forms, reports with its help are described. Export and import of data, as well as publication of data on a Web server are considered. Shows how to design, build, and test client-server applications. Attention is paid to the features of the next version of the popular package, as well as additional capabilities for working with XML Web services and interaction with other applications (Microsoft Visual Studio .NET and Microsoft SQL Server 2000). Numerous examples and illustrations will help you quickly master and successfully apply the presented material in practice. For programmers and database developers UDC 681.3.068 + 800.92 Visual FoxPro 9 LBC 32.973.26-018.1 Group of preparation of the publication: Editor-in-chief Deputy. ch. editor Head. editorial office Editor DTP Proofreader Cover design Head. production Ekaterina Kondukova Igor Shishigin Grigory Dobin Natalia Dovgulevich Natalia Karavaeva Victoria Piotrovskaya Igor Tsyrulnikova Nikolay Tverskikh License ID No. 02429 dated 24.07.00. Signed for printing on 18.03.05. Format 70 1001/16. Offset printing. CONV. print l. 49. Circulation 5000 copies. Order No. "BHV-Petersburg", 194354, St. Petersburg, st. Yesenin, 5B. Sanitary and Epidemiological Conclusion for Products No. 77.99.02.953.D.006421.11.04 dated 11.11.2004 issued by the Federal Service for Supervision of Consumer Rights Protection and Human Welfare. Printed from finished transparencies in the State Unitary Enterprise "Printing House" Nauka "199034, St. Petersburg, 9 line, 12 ISBN 5-94157-632-3 © Omelchenko L. N., Shevyakova D. A., 2005 © Design, publishing house" BHV- Petersburg ", 2005 CONTENTS INTRODUCTION ............................................ .................................................. ............. 1 How to use this book ................................. .................................................. ................. 2 How the book is structured ............................. .................................................. ............................ 2 Special elements of the book .................. .................................................. ........................ 3 CHAPTER 1. GETTING TO KNOW VISUAL FOXPRO .................. .................................... 5 Modern relational DBMS .......... .................................................. ......................... 7 Visual FoxPro Objects ..................... ..................................... ............................................. 10 What's New in Visual FoxPro 9.0 ............................................... ........................ 12 CHAPTER 2. GETTING STARTED WITH VISUAL FOXPRO ................. .............................. 15 Starting Visual FoxPro ................ .................................................. ........................................ 15 Main Window of Visual FoxPro ..... .................................................. ....................................... 15 Taskbar Manager ....... ..................... .................................................. ...................... 27 Visual FoxPro Help System ....................... .................................................. .......... 30 CHAPTER 3. THE PROJECT AS A MEANS OF COMBINING THE ELEMENTS OF THE APPLICATION .............................. ............................. 39 Creating an application project ................. .................................................. ...................... 39 Menu-driven project management ...................... .................................................. .45 Project element management ............................................. ......................................... 46 Using the wizard to create a project ... .................................................. ......... 47 CHAPTER 4. CREATION OF THE PROJECT DATABASE ................................. ............ 57 Creating a database in the project window ............................... ............................................. 57 Creating a database outside the project ................................................ ................................. 61 Tables - the basis of the database ........... .................................................. ......................... 62 Table design window ..................... .................................................. ......................... 68 Indices ....................... .................................................. .................................................. ... 78 Relationships between tables ........................................... ................................................ 82 Integrity data ................................................. .................................................. ....... 85 IV Contents CHAPTER 5. FORM AS A MEANS OF ENTRYING AND EDITING DATA .............................. .......................... 89 Creating a Form Using the Wizard .................. .................................................. ......... 90 Starting the form ..................... .................................................. .............................................. 97 Form Objects. .................................................. .................................................. ............. 97 Actions performed with form objects .............................. ................................. 101 Changing the sequence of entering information in the form fields ......... ................. 105 CHAPTER 6. FORM DESIGNER ................... .................................................. 109 Form designer window .............................................. .................................................. 109 Creating a Shape ............................................... .................................................. ............. 113 Setting shape parameters ................................. .................................................. ..... 114 Form Environment ......................................... .................................................. ...... 116 Procedure for setting shape parameters ............................. 122 Placing objects in the shape ... .................................................. .................................. 123 CHAPTER 7. CREATING AND PRINTING REPORTS ........ ............................................. 157 What is a report. .................................................. .................................................. ............ 157 Recommendations for Report creation ................................................ ................................ 157 Reporting tools .............. .................................................. .............................. 158 Using the wizard to create a single-table report ............. ...................... 158 Viewing the prepared report ........................ .................................................. ....... 168 Print report ........................................ .................................................. .......................... 169 CHAPTER 8. CREATING A REPORT USING THE REPORT DESIGNER .............. ................................................. 173 Report designer window ............................................... ............................................. 173 Using the Quick Report Command for placing fields .................................... 175 Setting the environment of the report environment ... .................................................. .. ..................... 179 Properties of report objects ......................... .................................................. ..................... 182 Placing objects in the report ........................ .................................................. ............. 188 Adding Header and Totals Areas to the Report ............................. ............................ 200 Creating a simple report .................. .................................................. ........................... 201 Creating a free-form report ................. .................................................. .......... 203 Creating a tabular report .................................... .................................................. ..... 205 Grouping data in the report ........................................ ................................................. 207 Using variables in the report .............................................. ............................... 211 Report Page Layout ............... .................................................. .............................. 213 Multi-column report ................. .................................................. .............................. 215 CHAPTER 9. REQUESTS TO THE DATABASE ............ ................................................. 217 Query Builder ................................................ .................................................. ... 218 Formation of the list of fields p of the resulting query table ............................... 221 Order By tab of the query designer .......... .................................................. .......... 225 Setting conditions for selecting records .................................. .......................................... 227 Multi-table queries ..... .................................................. ........................................ 233 Grouping of query fields ...... .................................................. .................................... 237 Changing the names of fields in the request ........ .................................................. ........ 241 Chapter V CHAPTER 10. CROSS TABLES AND DIAGRAMS .............................. 243 Cross tables ................................................. .................................................. . 243 Data export .............................................. .................................................. ............... 254 Construction diagrams ................................................. .................................................. ... 254 CHAPTER 11. APPLICATIONS MENU ......................................... ......................... 261 Preparing to create a menu .................... .................................................. .................. 261 Actions required to create a menu ......................... ....................................... 262 Launching the menu builder ....... .. .................................................. .................................. 262 Menu creation ............. .................................................. .................................................. 264 Saving, generating and launching menus ........................................... .............................. 278 Creating a Popup Menu ................ .................................................. .................... 279 CHAPTER 12. CREATING THE APP HELP SYSTEM ............... 281 Status bar ... .................................................. .................................................. ..... 281 Usage dialog boxes.................................................. ................................. 282 Creating an HTML Help System .......... .............................................. 285 Using the Help System in applications ................................................ .. 293 CHAPTER 13. MANAGING THE PROJECT AND CREATING THE APPLICATION .......... 297 Defining the properties of the project window ........................ .................................................. ..... 297 Setting project parameters ......................................... .................................................. 299 Setting the main program of the project ............................................. ......................... 302 Using the Exclude Option ..................... .................................................. ................. 303 Cleaning the project from deleted files .................................................. ....................... 303 Building the project ........................ .................................................. ............................... 303 Visual FoxPro Component Gallery .............. .................................................. ............... 306 CHAPTER 14. VALIDITY CONDITIONS, STORED PROCEDURES, TRIGGERS, SUBMISSION OF DATA ..................... ................. 315 Conditions for the validity of data entry at the record level ......................... .................. 315 Conditions for the validity of data entry at the table field level ....................... ......... 323 Using Data Views ..................................... .................................... 325 CHAPTER 15. ADVANCED DATA ENTRY FACILITIES ...... ........................ 337 Displaying data in a tabular form .................. ....................................... 337 Creating a Tabbed Form ...... ............................... .................................................. . 356 Form set .............................................. .................................................. ...................... 360 Timer .......................... .................................................. .................................................. . 361 Adding data to the list ............................................ ............................................. 364 CHAPTER 16. LIBRARIES CLASSES AND ACTIVEX COMPONENTS ................. 367 Using Class Libraries ........................ .................................................. ...... 367 Using ActiveX-components in the form ..................................... ........................ 374 Using the Object Browser ...................... .................................................. ......... 390 CHAPTER 17. ADVANCED REPORTING TOOLS ..................... 395 Using Data Views in Reports ......... ..................... .............................. 395 Labels .................. .................................................. .................................................. ..... 396 Using one-to-many relationships in reports ................................. ........... 404 VI Table of Contents CHAPTER 18. ADVANCED FACTORS OF DATA ... 409 Output of query results .. .................................................. ..................................... ..... 409 Saving query results in HTML format ...................................... ............... 412 Using the Select command in programs ............................. .................................. 414 CHAPTER 19. VISUAL OBJECT-ORIENTED PROGRAMMING ....... .................................................. ......... 419 Using Classes ...................................... .................................................. ........... 419 Using nested objects ................................... .......................................... 434 Custom Classes ... .................................................. ......................................... 437 Viewing class information and defining an icon for its designations .......... 447 Formation of the list of libraries used in constructors of forms and classes ........................... .................................................. ....... 450 Create User-Based Forms lski classes ................................................ .. 450 Using a Form to Create a Class .......................................... ....................... 454 Class Browser ....................... .................................................. ............................ 455 Creating a toolbar .................. .................................................. ................. 458 CHAPTER 20. MULTIPLAYER WORK IN THE LOCAL NETWORK ........................ ............................................... 463 Locking types .................................................. .................................................. ......... 463 Automatic blocking ...................................... .................................................. .... 463 Full table lock and change lock ... ....... 465 Locking a table ........................................ ..................................... ........................... 466 Locking recordings .................... .................................................. ................................... 466 Unlocking tables and records ......... .................................................. ................ 468 Data sessions ............................. .................................................. ............... 469 Using buffers ................................ ...................... ............................................ 470 Using transactions ... .................................................. ........................................ 474 CHAPTER 21. LINKING AND IMPLEMENTATION OF OBJECTS, EXPORT AND DATA IMPORT ............................................... ...................... 475 Visual FoxPro and OLE Objects ..................... .................................................. .................. 475 Linking an OLE Object ........................... .................................................. ................... 481 Editing an OLE object .......................... .................................................. ............. 484 Deleting an OLE Object ................................ .................................................. .................. 484 Using Object-Oriented Programming .......................... .... 484 Transferring Data from Visual FoxPro to Other Applications ..................................... ...... 486 Import Dan n ................................................. .................................................. ............. 488 Using data from Visual FoxPro in Microsoft Word ............................ ............. 491 CHAPTER 22. REMOTE DATA REPRESENTATIONS .............................. ..... 497 Defining an ODBC Data Source ........................................ ................................ 497 Named Connection ............... .................................................. .............................. 500 Connection constructor ................. .................................................. ............................. 500 Configuring Remote Views and Connections in the Options Dialog Box .......... .................................................. ................................... 503 Creating a Remote Data View .......... .................................................. ... 505 Table of Contents VII Shared Connections ... .................................................. ..................... 513 Combining local and remote data representation ..................... .... 514 Customizing a View Using a Database Dictionary ...................................... 516 CHAPTER 23. DATA TRANSFER FROM VISUAL FOXPRO TO CLIENT-SERVER PLATFORM .................................... ........... 519 Using the Growth Wizard to Transfer Data to a Database SQL data Server ................................................. ............................................... 519 CHAPTER 24 . PUBLICATION OF DATA ON THE WEB SERVER ................................. 531 Web Publishing Wizard ... .................................................. .............................................. 531 Configuring Web Settings -pages using the wizard ........................................ 535 Creating a Web page .................................................. ............................................... 539 Editing the created Web pages ............................................... .................... 543 CHAPTER 25. SETTING VISUAL FOXPRO PARAMETERS ...................... .......... 545 Options of the tabs of the Options window ................................... ................................................. 546 APPENDIX. INSTALLING VISUAL FOXPRO .............................................. 573 System requirements ............................................... .................................................. ..... 573 Installing Visual FoxPro ......................................... .................................................. ....... 573 Customizing Visual FoxPro ....................................... .................................................. ........ 575 GLOSSARY ........................................ .................................................. ........... 579 INDEX .................................... ........................................ 589 VIII CONTENTS INTRODUCTION In recent years, rumors have sprung up from time to time that Microsoft will end support software product Visual FoxPro. But again they turn out to be the intrigues of ill-wishers. And another a new version Visual FoxPro 9.0 is a direct confirmation of this. Despite the emergence of new database management systems, Visual FoxPro continues to be one of the most popular programs in this area. This is primarily due to the fact that when creating new versions, Microsoft maintains compatibility with previous versions. Therefore, the applications you create can be used in the future. Visual FoxPro implements all the attributes of relational database management systems. The database maintains data integrity using primary keys and relationships between tables. You can use triggers and stored procedures to handle events for adding, deleting, or modifying table records using the database itself. Visual FoxPro is an object-oriented, visual-programmable, event-driven language that fully meets the new requirements for modern software design and implementation tools. Visual FoxPro can be used by users different levels preparation. If you are just starting to master Visual FoxPro and you need to develop a simple application as soon as possible, the wizards for creating databases, tables, applications, forms, reports, etc. will help you. For the development of large and complex projects, appropriate designers and an object-oriented language are used , which allows you not only to use base Visual FoxPro classes and external libraries, but also to create custom classes. This book is of interest both for beginners familiar with Visual FoxPro 9.0, and for those with experience with this system of developers. The book sequentially describes the entire process of creating complete applications: creating a database and its tables, designing forms for entering and viewing data, creating queries and reports, as well as other means of displaying and processing database information. The book contains a large number of illustrations that will help you get acquainted with the material presented in it. 2 INTRODUCTION HOW TO USE A BOOK If you are just starting to learn Visual FoxPro, the chapter order suggested will allow you to go from easy to difficult to learn this software. If you are familiar with Visual FoxPro, you do not need to read the book from start to finish. In the table of contents of the book, you can see which chapters are of most interest to you, and study only them. You can learn a lot by just skimming through the book. It has specially highlighted moments that will catch your eye when you scroll through it. How to build a book The book assumes a sequential study of material from simple to complex. Chapters 1 and 2 of the book are introductory. You will learn how to start Visual FoxPro, how to get help in it, get acquainted with the elements of the main program window and what is new in Visual FoxPro 9.0 compared to previous versions. In Chapter 3, you will learn about the project, which is a means of combining elements of an application. After completing Chapter 4, you will learn how to create a database, its tables, indexes, relationships between tables, and determine data integrity conditions. Chapters 5 and 6 explore how to create forms for entering and editing data using a wizard and form designer. Chapters 7 and 8 focus on designing simple reports. After reading Chapter 9, you can create a query of any complexity. Chapter 10 introduces you to creating crosstabs and charts. The application uses a menu to launch forms, reports and programs. Chapter 11 talks about creating such an application menu. After reviewing the first eleven chapters and analyzing the examples presented to your attention, you can create applications yourself. The following chapters build on the knowledge gained in the first chapters and are devoted to advanced tools for creating forms, queries, reports. Chapter 12 discusses how to develop an effective HTML help system for your application. Chapter 13 discusses some additional questions project management, including the creation of an executable (exe) file. Chapters 14 through 18 discuss advanced database management, multi-tabular forms and reports, and the use of ActiveX components in forms. Chapter 19 introduces you to the object-oriented approach to building database applications. You will learn how to create classes and objects based on them. Chapter 20 is devoted to the work of Visual FoxPro on a local network. INTRODUCTION 3 Visual FoxPro is not an isolated system and can effectively interact with other Windows applications. After reading Chapter 21, you will learn how to work with compound objects (OLE), export and import data. You will learn how to install the ODBC driver, how to create a remote data view and configure its parameters in Chapter 22. Chapter 23 introduces you to porting data from Visual FoxPro to a client / server platform using the Growth Wizard. Visual FoxPro has the ability to generate a Web page using the information contained in the database. This is discussed in Chapter 24. For effective work Visual FoxPro uses the parameters that are discussed in the last chapter of the book. The appendix walks you through installing Visual FoxPro 9.0. The book also contains a glossary describing Visual FoxPro terms. Special Elements of the Book There are many special inserts in the book that are highlighted in a special way. They contain Additional Information that makes it easier to read and search for information: NOTE Notes are about the consequences of certain actions. NOTE Tips provide some tips you need to know to get the most out of Visual FoxPro. NOTICE Warnings should help you avoid problems. They tell you what to fear and what to do to avoid mistakes. The book uses different types of fonts: new terms are in italics; the text that you must enter from the keyboard is in bold italic; menu commands, names of buttons, tabs, options, check boxes, dialog boxes, areas, etc. are in bold; names of functions, properties, methods, databases, tables, table fields are in monospaced font. The two keys connected by a plus sign is a key combination. Press the first key and, without releasing it, press the second. Then release both. The authors express their gratitude to the publishing house "BHV-Petersburg" for long-term fruitful cooperation and assistance in the preparation and writing of the book. 4 Introduction Chapter 1 About Visual FoxPro The changes taking place in our country in recent years could not but affect the fields of informatics and computer technology. Ten years ago, working with databases was a lot of professional programmers... The systems themselves were not designed to simple user... The main consumer of such systems was the military-industrial complex. With the emergence of banks, joint-stock companies, private companies, databases have found wider application. People understand that information is money. Losing it or getting it late can be costly. This is what explains such a rapid growth information technologies and the rapid development of database management systems (DBMS). Relational Databases The first database management systems emerged in the mid-1960s and supported a hierarchical data model in which parent / child relationships existed between records. After a short time, network databases were developed, based on a much more complex network model... Each of these models had advantages and disadvantages that played a key role in the development of the relational model. In 1970, an article by IBM researcher Dr. E. F. Codd on the relational data model revolutionized the way we store and process information. The first relational databases were developed on the basis of this model in the seventies of the last century, and now they are considered as the standard for modern commercial DBMS. In relational databases, all information is summarized in tables, the rows and columns of which are called records and fields, respectively. These tables were called relations1, so the model was called relational. Entries in tables are not repeated. Their uniqueness is provided by a primary key containing 1 Relationship - a mathematical term from set theory, which formed the basis of the relational data model. IN English language the word "relation" corresponds to the word "relation", hence the name "relation". - Ed. Chapter 1 6 is a set of fields that uniquely identify a record. For quick search information in the database, indexes are created on one or more fields of the table. Index values are stored in an ordered manner and contain references to table records. Primary and foreign keys are used to automatically maintain the integrity of related data in different tables. To fetch data from multiple related tables, the values of one or more of the matching fields are used. For example, the registration table is long-distance calls can contain the following information: Íîìåð çàêàçà Êîä óñëóãè Íîìåð òåëåôîíà Äàòà ðàçãîâîðà Êîä ãîðîäà Ïðîäîëæèòåëüíîñòü ðàçãîâîðà Ñòîèìîñòü Ïðèìå ÷ àíèå Records of long-distance calls are recorded in the registration book, as a table in chronological order (Figure 1.1.). Each line has the same structure and consists of eight fields. In this example, these are the following fields: Order number, Service code, Phone number, Call date, City code, Call duration, Cost. Fig. 1.1. LOGGING INTERMEDIATE SPOTS BY ARRAY In relational databases, fields can have different data types (numeric, string, date type, etc.), but for each record, the data type of the field remains the same. One of the important advantages of the database is the fast retrieval of the information stored in it. Using the telephone address book, in which the data is sorted by last name, you can find a phone number by the last name of its owner. However, if the long distance book entries are ordered chronologically, you will have to spend a significant amount of time getting Visual FoxPro 7 a list of customers who have ordered a call to a specific city, or figuring out which area the most profitable subscribers live in. telephone company with long conversations. Computer databases come to the rescue. They, despite the huge amount of information stored in them, provide a high speed of searching for the necessary information. In such databases, the user can search for any parameter of interest. Moreover, computer databases are very compact. A database containing several thousand records can fit on one floppy disk. Database management systems are used to create a database, change its structure, edit and retrieve data. Modern relational database management systems contain: a set of tools for creating tables and relationships between related tables; database administration tools; developed user interface which allows you to access the information stored in the database; development tools for applications using databases. In fig. 1.2 shows an example of intercity accounting telephone conversations using two relational database tables in Visual FoxPro. Fig. 1.2. Reads Intermediate Phone Speakers Using the Television Tables Chapter 1 8 Fig. 1.3. Reading in the standard video, containing information about the customers of the telephone company Fig. 1.4. Information Writing, Reference Information With Visual FoxPro 9 Fig. 1.5. Graphical presentation of information about the number of hardware. For example, you can get information about all long-distance calls of a certain customer for any period of time; print the entire table or just selected records and fields in various formats. For example, in Fig. 1.3 shows a tabular report containing the addresses of the telephone company customers. In fig. 1.4 shows one of the variants of a newsletter containing the names and surnames of clients from the same table; display database information graphically. For example, in Fig. 1.5 data on the number of long-distance calls for clients are displayed in the form of a diagram; carry out the necessary calculations when generating reports and selecting data from tables. Currently, there are more than ten popular DBMS for personal computers. Traditionally, one of the most widespread in Russia and the CIS countries is the Visual FoxPro DBMS, the new version of which, Visual FoxPro 9.0, contains additions and improvements that expand the capabilities of the system. 10 Chapter 1 Visual FoxPro Objects Visual FoxPro consists of individual components that are used to store, display, and edit information. In Visual FoxPro, all information is stored in a database, which consists of tables, relationships between tables, indexes, triggers, and stored procedures. Each table has a unique name and is stored in a separate file, the name of which is the same as the name of the table. The created file has the dbf extension. Each table you create can have indexes associated with it, which are used to organize data and quickly find the records you need, and one table can have multiple indexes. Separate files are used to store the values of the Memo and General fields. Memo fields of tables contain text information, and General fields are typically used to store binary information and data from other Windows applications. Visual FoxPro implements triggers that allow you to centrally process events that occur when any changes to the database are made. You can also create stored procedures that are part of the database and can be used to describe tables, validate input data, define default values, and so on. Data views are an extremely convenient and useful means of accessing a database. Data Views allow you to combine table data and display it in more convenient form ... You can select only the table fields you are interested in, combine multiple fields into one field, calculate totals, and specify new table field names. Typically, the number of views in a database far outnumbers the number of tables. As the database is used, their number is constantly growing. In many information systems, access to data, including viewing, adding and editing, is carried out only through the use of data views. This approach allows for flexible control over access to information. When using views to select data in forms, reports, when creating queries, and in programs, the same rules apply as for tables. Editing the data included in the presentation is possible only under certain conditions. For example, if it is created based on only one table. Forms, reports, queries and programs are used to display and edit data. Designers are used to create forms, reports, and queries. Therefore, these components are often referred to as design objects. Forms and reports are composite objects because they are composed of smaller objects (such as fields, buttons, charts, frames, OLE components, and so on) called interface objects. Forms are used to view or enter data into tables. Data can be entered directly into tables, but using a form is a faster and more efficient way to enter. The form contains some or all of the table fields in which you enter information. You can use the Form Builder or the Form Designer to create forms. The Form Wizard contains a number of templates that define the relationship between the faces that are placed on the form in the Visual FoxPro 11 tabs, the way the data is displayed, and the order in which the fields are placed. A form designer is used to create complex shapes. Reports are used to print the information contained in the database. Examples of reports are price list of goods, list of buyers, turnover list. As a rule, reports are created in the event that information needs to be transmitted to someone in hard copy. To create reports in Visual FoxPro, just like for forms, you use a wizard and a report designer. Using the Report Wizard, you can quickly create your own report based on the templates available. Using the Report Designer allows you to create reports of arbitrary complexity, including multi-level data grouping and the placement of calculated fields. Queries are a means of fetching data from one or more tables. In Visual FoxPro, you can use either the Query Designer or the specialized Structured Query Language (SQL) to create a query. Query results can be displayed in a form, displayed as reports and charts, or saved in a table you specify. Programs written in the Visual FoxPro language are object-oriented. With the help of them, you process events in the form, create objects, perform various calculations, manage the database. For convenience, you can combine programs into libraries. To create forms in Visual FoxPro, you can use not only base classes, but also create your own. For example, you can define a form class that has a specific background color and a standard set of buttons for manipulating data. To standardize development, it is helpful to have one or more custom classes for each base class. Classes created in Visual FoxPro are stored in class libraries. To combine the components of the created application, a project is used, which includes all the components listed above. Using a project simplifies application development and maintenance. Each component is stored in a separate file, and the names of the files containing the main components you specify yourself, and the names of the files containing the objects associated with the table coincide with the name of the table. Based on the type of object it contains, Visual FoxPro automatically assigns an extension to each file to help identify the object. The list of file extensions is given in table. 1.1. Table 1.1. Ðàñøèðåíèÿ èìåí ôàéëîâ îáúåêòîâ Visual FoxPro Íàèìåíîâàíèå îáúåêòà Ðàñøèðåíèÿ Ïðîåêò prj, fpc, cat, pjx, pjt Áàçà äàííûõ dbc Òàáëèöà Visual FoxPro dbf Ñîñòàâíîé èíäåêñíûé ôàéë cdx Memo-ïîëå è ïîëå òèïà General frt Ãëàâà January 12 Òàáëèöà 1.1 (îêîí ÷ àíèå) Íàèìåíîâàíèå îáúåêòà Ðàñøèðåíèÿ Ôîðìà scx Çàïðîñ qpr Îò ÷ åò frx, frm Ïî ÷ òîâàÿ íàêëåéêà lbx, lbl ìåíþ mnx áèáëèîòåêà êëàññà vcx Ïðîãðàììà, áèáëèîòåêà ïðîãðàìì, òåêñò ìåíþ, prg, fxp, mpr, qpr òåêñò çàïðîñà Ðèñóíîê bmp, jpg, gif, ico, dib , cur, ani Recording wav This New Arrival in Visual FoxPro 9.0 Visual FoxPro is an ever-evolving system. Compared to the previous version, Visual FoxPro 9.0 takes one more step in expanding the system's functionality, improving the existing tools related to the development environment interface and error handling, adding new commands, base classes and functions, and expanding the existing ones. The new version has all the capabilities for working with XML Web services, as well as improved compatibility with Microsoft Visual Studio .NET and Microsoft SQL Server 2000. Visual FoxPro has extended table designer tools. New data types can be used for table fields: Binary Blob and Text Varbinary. The Blob data type is used for structures containing information about a data block. It is used to store binary information of any type, for example, ASCII characters, executable files, byte streams. The Varbinary data type contains hexadecimal values. It is similar to the Character type, but for data of this type, empty spaces are not filled with insignificant information. A new type of index, Binary, has been introduced, which is based on Boolean expressions and is used for both free tables and database tables. This index takes up significantly less space and therefore improves the speed of index use. Objects placed on the form have new properties. Let's consider the most interesting ones. The Anchor property sets the absolute and relative positions and sizes of the object relative to all four sides of the container object, solving the problem of automatically positioning and resizing objects on the form when it is resized when the Resize event occurs. About Visual FoxPro 13 The Rotation property of Label, Line, and Shape objects allows you to display labels for large objects of the EditBox class as text flowing from bottom to top. The AutoComplection property of the TextBox object allows you to remember the values entered in the field and, when you enter a new value, to show this list for easier input. This property is useful when entering data in a field that has a small set of options. The AutoHideScrollBar property of the ListBox allows you to hide the scroll bar when all rows are visible and show it back when not all rows fit in the ListBox. The PictureMargin and PictureSpacing properties of the CommandButton, OptionButton, and CheckBox objects control the position of the image relative to the edge and text of the object. The MousePointer property for the columns (Column object) and headers (Header object) of the Grid object at the stage of class or form editing sets the required form of the mouse pointer when it enters the field of this object. The SET PATH TO command now has an ADDITIVE property that allows you to add new paths to existing ones, and the length of all paths has increased from 1024 to 4096. In the Project Manager, you can now execute the Modify command when you select a class library, and not a separate class of this library. Visual FoxPro 9.0 launches the Class Browser with the selected class library. Developers will be pleased with the changes in the report designer. Configuring all objects (location of an object in the report strip, style of design, printing conditions, protection against alteration) placed in the report is carried out using the properties dialog box. All parameters of the report itself (page layout, adding header and total areas to the report, grouping data, setting report variables, saving the report as a class) are also set using the Report Properties dialog box. The changes have been made to custom properties and methods. When you create new properties and methods, you can assign default / initial values to them. Enhanced options for customizing Visual FoxPro, carried out from the Options dialog box, which is opened by the Options command from the Tools menu. Enlarged the list of file groups defined by the File Locations tab. The View tab now has a List display count that lets you set the maximum number of list items to display when using IntelliSense. The set of parameters set on the Reports tab has been significantly expanded. 14 Chapter 1 Chapter 2 Getting Started with Visual FoxPro You are getting started with Visual FoxPro 9.0. Many of the things you will have to work with (menus, toolbars, dialog boxes) will seem familiar because they are specific to the Windows environment. Starting Visual FoxPro To start the program from the Windows main menu, follow these steps: 1. Click the Start button located at the bottom of the screen. 2. In the opened Windows main menu, select the Programs command. The menu for this command appears. 3. Select the Microsoft Visual FoxPro 9.0 command from the menu. The main window of Visual FoxPro 9.0 will open on the screen (Fig. 2.1). TIP To launch Visual FoxPro 9.0 faster, you can create a shortcut on the desktop and assign keys to it quick call... Then it will be enough to press the specified key combination in any Windows window, and the program will start. In addition, for the convenience of launching the application, you can use the panel Quick start Windows system by placing the Visual FoxPro program icon on it. Visual FoxPro Main Window 2.1 shows the main window of Visual FoxPro as it looks after starting the program. It has seven main objects: the window title, menu bar, toolbar, status bar, work area, Command window, and the Task Pane Manager dialog box. The title bar is at the top of the main window and contains three objects: a copy of the Visual FoxPro program icon, the title of the main window, and icons to control that window. The menu bar contains a hierarchical Visual FoxPro menu. The list of menu items depends on the type of active window. 16 Chapter 2 Fig. 2.1. Visual FoxPro 9.0 Main Window Visual FoxPro provides the user with a wide variety of toolbars for working with databases, forms, reports, and queries. These toolbars contain a set of buttons, and this set depends on the purpose of the particular toolbar. After starting Visual FoxPro, the standard toolbar is displayed on the screen. At the bottom of the main window there is a status bar, which displays information about current state active window, brief description of the selected toolbar button or menu item. The information displayed in the status bar depends on the type of active window. For example, in the form designer window, the status bar displays the name of the active form object, and when viewing the table in Browse mode, the name of the open table is displayed on the left side of the status bar, and the number of the current record and the operating mode indicator in the middle of the status bar. In Visual FoxPro 9.0, the main window displays the Task Pane Manager by default. It contains a list of recently opened projects and databases, help launch commands and wizards for creating a database and project, examples that you can use in development, and useful links to sites on the Internet. Getting Started with Visual FoxPro 17 As you work, the main Visual FoxPro window opens windows for designers of forms, reports, queries, projects, and other windows. All of them are children of the main window and are closed when it is closed. In addition, if you did not close the project window you were working with when exiting Visual FoxPro, it will open by default in the main window the next time you start the program. System menus and system buttons The title of the main window contains a small copy of the program icon, the text "Microsoft Visual FoxPro" and buttons to control the size of the main window. When you click on the icon of the icon, a system menu opens, containing commands for moving and resizing the main window. Table 2.1 shows the commands available from the system menu. Table 2.1. Íàçíà ÷ åíèå êîìàíä ñèñòåìíîãî ìåíþ Êîìàíäà Íàçíà ÷ åíèå Âîññòàíîâèòü Âîññòàíàâëèâàåò ïðåäûäóùèé ðàçìåð îêíà ïîñëå ìèíèìèçàöèè èëè ìàêñèìèçàöèè Ïåðåìåñòèòü Àêòèâèçèðóåò ãëàâíîå îêíî Visual FoxPro è ïîçâîëÿåò ïåðåìåùàòü åãî ñ ïîìîùüþ êëàâèø ïåðåìåùåíèÿ êóðñîðà Ðàçìåð Àêòèâèçèðóåò ãëàâíîå îêíî Visual FoxPro è ïîçâîëÿåò èçìåíÿòü åãî ðàçìåðû ñ ïîìîùüþ êëàâèø ïåðåìåùåíèÿ êóðñîðà Ñâåðíóòü Ñâåðòûâàåò ãëàâíîå îêíî FoxPro äî ðàçìåðà êíîïêè è ïîìåùàåò åå íà ïàíåëü çàäà ÷ windows Ðàçâåðíóòü Ðàçâåðòûâàåò ãëàâíîå îêíî Visual FoxPro âî âåñü ýêðàí Çàêðûòü Çàêðûâàåò ãëàâíîå îêíî ïðîãðàììû Visual FoxPro TIP to quickly close the Visual FoxPro program, double-click on a small copy of the application icon in the header of the main window ... To quickly restore / maximize the main window, double-click on the title bar. The Microsoft Visual FoxPro text of the main window title can be easily changed, if necessary, by assigning any other name to the main Visual FoxPro window, or by removing the name altogether. To do this, enter the following command in the command window: MODIFY WINDOW SCREEN TITLE "(! LANG: New title of the main window"
или
_SCREEN.caption = "Новый заголовок главного окна"
В !} right side the header contains the window control buttons. Their purpose is described in table. 2.2. 18 Chapter 2 Table 2.2. Íàçíà ÷ åíèå êíîïîê óïðàâëåíèÿ îêíîì Êíîïêà Íàçâàíèå Íàçíà ÷ åíèå Ñâåðíóòü Ñâîðà ÷ èâàåò ãëàâíîå îêíî FoxPro äî ðàçìåðà êíîïêè è ïîìåùàåò åå íà ïàíåëü çàäà ÷ Windows Âîññòàíîâèòü îáðàòíî Óìåíüøàåò ðàçìåð ðàçâåðíóòîãî îêíà, ïîçâîëÿÿ â äàëüíåéøåì èçìåíÿòü åãî Ðàçâåðíóòü Ðàçâåðòûâàåò ãëàâíîå îêíî Visual FoxPro âî âåñü ýêðàí Close Opens the main window of Visual FoxPro, provides a large number of Visual FoxPro reporting toolbars, provides a large number of Visual FoxPro reporting tools. They will be discussed in detail in the respective chapters. First, let's examine the standard toolbar (Fig. 2.2), which is used in all modes of operation. Fig. 2.2. Standard Toolbar Visual FoxPro The functions of the standard toolbar buttons are described in table. 2.3. Table 2.3. Íàçíà ÷ åíèå êíîïîê ñòàíäàðòíîé ïàíåëè èíñòðóìåíòîâ Êíîïêà Íàçâàíèå Íàçíà ÷ åíèå New (Íîâûé) Ïîçâîëÿåò ñîçäàòü íîâûé ôàéë (ïðîåêò, áàçó äàííûõ, òàáëèöó, çàïðîñ, ôîðìó, îò ÷ åò, êëàññ) Open (Îòêðûòü) Îòêðûâàåò ñóùåñòâóþùèé ôàéë Save (Ñîõðàíèòü) Ñîõðàíÿåò îòêðûòûé ôàéë Print One Copy (ïå ÷ àòàòü îäíó êîïèþ) ïå ÷ àòàåò ñîäåðæèìîå àêòèâíîãî îêíà Print Preview (Ïðîñìîòð ïå ÷ àòè) Îòêðûâàåò îêíî ïðåäâàðèòåëüíîãî ïðîñìîòðà ïå ÷ àòàåìîãî äîêóìåíòà Cut (Âûðåçàòü) Óäàëÿåò âûäåëåííûé òåêñò èëè âûäåëåííûå îáúåêòû è ïîìåùàåò èõ â áóôåð Copy (Copy) Copies in the buffer of the selected text or the attached objects, do not delete them. Paste. Äåéñòâèå ýòîé êíîïêè çàâèñèò îò òîãî, â êàêîì èç ðåæèìîâ âû ðàáîòàåòå Íà ÷ àëî ðàáîòû ñ Visual FoxPro 19 Òàáëèöà 2.3 (îêîí ÷ àíèå) Êíîïêà Íàçâàíèå Íàçíà ÷ åíèå Undo (Îòìåíèòü) Îòìåíÿåò âûïîëíåííûå äåéñòâèÿ Redo (Âîññòàíîâèòü) Âîññòàíàâëèâàåò îòìåíåííûå äåéñòâèÿ Run (Âûïîëíèòü ) Çàïóñêàåò íà âûïîëíåíèå Modify Form (ìîäèôèöèðîâàòü ôîðìó) Ïîçâîëÿåò ìîäèôèöèðîâàòü SÑX-ôàéë, ñâÿçàííûé ñ äàííîé ôîðìîé Databases (Áàçû äàííûõ) Ñîäåðæèò ñïèñîê îòêðûòûõ áàç äàííûõ Command Window (êîìàíäíîå îêíî) Îòêðûâàåò êîìàíäíîå îêíî Data Session Window (îêíî ñåàíñà äàííûõ) Îòêðûâàåò îêíî Data Session Properties Window (Îêíî ñâîéñòâ) Îòêðûâàåò îêíî Properties (Ñâîéñòâà), èñïîëüçóåìîå äëÿ íàñòðîéêè ñâîéñòâ Document View Window (Îêíî ïðîñìîòðà äîêóìåíòà) Îòêðûâàåò îêíî Document View (Ïðîñìîòð äîêóìåíòà), â êîòîðîì îòîáðàæàåòñÿ ñïèñîê ïðîöåäóð, ôóíêöèé îòêðûòîé â îêíå ðåäàêòîðà ïðîãðàììû Class Browser ( Classes View) Opens the Class Browser window, preset for the Object Browser (View îð îáúåêòîâ) Îòêðûâàåò îêíî Object Browser (Îáçîð îáúåêòîâ), ïîçâîëÿþùåå ïðîñìàòðèâàòü êëàññû, ñâîéñòâà, ìåòîäû, ñîáûòèÿ è êîíñòàíòû âûáðàííûõ áèáëèîòåê Task Pane (Ïàíåëü çàäà ÷) Îòêðûâàåò îêíî Task Pane Manager (Ìåíåäæåð ïàíåëè çàäà ÷) Toolbox (Èíñòðóìåíòàðèé) Îòêðûâàåò îêíî Toolbox (Instrument), which contains the items that were used by the operator when creating the display. appearance button, you cannot define its purpose, position the mouse pointer over the button. In this case, a tooltip with its name will appear under the cursor, and a short description of the specified button will be displayed on the left side of the status bar. By default, the standard toolbar is always present in the main Visual FoxPro window. If it does not appear on the screen, do the following: 1. Select Toolbars from the View menu. The Toolbars dialog box (Fig. 2.3) will open, which contains a list of all toolbars of the Visual FoxPro program. 20 Chapter 2 2. Check the boxes to the left of the names of those panels that you want to place in the main window. 3. Click OK. Using the check boxes at the bottom of the Toolbars dialog box, you can change the appearance of the toolbar buttons. The purpose of these flags is described in table. 2.4. Table 2.4. Íàçíà ÷ åíèå ôëàæêîâ äèàëîãîâîãî îêíà Toolbars Óñòàíîâêà ôëàæêà Íàçíà ÷ åíèå Color buttons (Öâåòíûå êíîïêè) Êíîïêè íà ïàíåëè èíñòðóìåíòîâ ñòàíîâÿòñÿ öâåòíûìè Large buttons (Áîëüøèå êíîïêè) Óâåëè ÷ èâàåòñÿ ðàçìåð êíîïîê ToolTips (Ïîäñêàçêà) Âûâîäèòñÿ êðàòêîå îïèñàíèå êíîïêè ïðè óñòàíîâêå êóðñîðà íà íåå Ðèñ. 2.3. The Toolbars Dialog Box After Visual FoxPro is installed, the standard toolbar is located at the top of the main window, but like all other toolbars, it can be moved anywhere on the screen. To do this, set the mouse cursor to any place free from buttons on the toolbar, press the mouse button and, without releasing it, move the panel to a new location. If you place the toolbar off the edge of the main Visual FoxPro window, you can resize it (Figure 2.4). Getting Started with Visual FoxPro 21 Fig. 2.4. Toolbar can be easily placed in any place of the main window. When you select a specific command, its submenu opens. If there are no others in the main Visual FoxPro window open windows, the menu bar contains File, Edit, View, Tools, Program, Window, and Help. When windows are opened, commands are added to the menu that apply only to the objects in the window. For example, when working with tables, the Table menu item is added to the main menu; when a form is opened on the screen, the Form item appears in the menu. NOTE When you select a command, a short description appears on the status bar. 22 Chapter 2 Executing Menu Commands Executing menu commands in Visual FoxPro is performed using standard Windows actions. Let's list the possible ways. When using a mouse, it is enough to place the cursor on the menu item containing the selected command and press the mouse button. If the command contains a submenu, select the required command from it. When using the keyboard, you must first activate the menu bar by pressing the key
Lyudmila Omelchenko Daria Shevyakova SELF-TEACHER St. Petersburg "BHV-Petersburg" 2005 UDC 681.3.068 + 800.92 Visual FoxPro 9 LBC 32.973.26-018.1 O-57 Omelchenko L. N., Shevyakova D. A. O-57 Self-instruction manual Visual FoxPro 9.0 ... - SPb .: BHV-Petersburg, 2005 .-- 608 p .: ill. ISBN 5-94157-632-3 Considered Visual FoxPro 9.0 - a powerful software package designed to build professional database applications. An integrated application development environment and the creation of basic objects such as classes, tables, queries, forms, reports with its help are described. Export and import of data, as well as publication of data on a Web server are considered. Shows how to design, build, and test client-server applications. Attention is paid to the features of the next version of the popular package, as well as additional capabilities for working with XML Web services and interaction with other applications (Microsoft Visual Studio .NET and Microsoft SQL Server 2000). Numerous examples and illustrations will help you quickly master and successfully apply the presented material in practice. For programmers and database developers UDC 681.3.068 + 800.92 Visual FoxPro 9 LBC 32.973.26-018.1 Group of preparation of the publication: Editor-in-chief Deputy. ch. editor Head. editorial office Editor DTP Proofreader Cover design Head. production Ekaterina Kondukova Igor Shishigin Grigory Dobin Natalia Dovgulevich Natalia Karavaeva Victoria Piotrovskaya Igor Tsyrulnikova Nikolay Tverskikh License ID No. 02429 dated 24.07.00. Signed for printing on 18.03.05. Format 70 1001/16. Offset printing. CONV. print l. 49. Circulation 5000 copies. Order No. "BHV-Petersburg", 194354, St. Petersburg, st. Yesenin, 5B. Sanitary and Epidemiological Conclusion for Products No. 77.99.02.953.D.006421.11.04 dated 11.11.2004 issued by the Federal Service for Supervision of Consumer Rights Protection and Human Welfare. Printed from finished transparencies in the State Unitary Enterprise "Printing House" Nauka "199034, St. Petersburg, 9 line, 12 ISBN 5-94157-632-3 © Omelchenko L. N., Shevyakova D. A., 2005 © Design, publishing house" BHV- Petersburg ", 2005 CONTENTS INTRODUCTION ............................................ .................................................. ............. 1 How to use this book ................................. .................................................. ................. 2 How the book is structured ............................. .................................................. ............................ 2 Special elements of the book. .................................................. ......................................... 3 CHAPTER 1. GETTING STARTED WITH VISUAL FOXPRO. .................................................. ... 5 Modern relational DBMS ........................................... .......................................... 7 Visual FoxPro Objects ... .................................................. ................................................. 10 What's New in Visual FoxPro 9.0 ........................................... ............................ 12 CHAPTER 2. GETTING STARTED WITH VISUAL FOXPRO ............. .................................. 15 Starting Visual FoxPro ............ .................................................. ............................................ 15 The main window of Visual FoxPro. .................................................. ........................................... 15 Task Tray Manager ... .................................................. ................................. .............. 27 Visual FoxPro Help System ............................... .................................................. .. 30 CHAPTER 3. THE PROJECT AS A MEANS OF COMBINING THE ELEMENTS OF THE APP ...................................... ..................... 39 Creating an application project ......................... .................................................. .............. 39 Menu-driven project management .............................. ........................................... 45 Project element management ... .................................................. ................................. 46 Using the wizard to create a project ........... .................................................. . 47 CHAPTER 4. CREATING THE PROJECT DATABASE ......................................... .... 57 Creating a Database in the Project Window ....................................... ..................................... 57 Creating a database outside the project ....... ........................................ .................................. 61 Tables - the basis of the database .......... .................................................. .......................... 62 Table designer window .................... .................................................. .......................... 68 Indices ...................... .................................................. .................................................. .... 78 Relationships between tables ............................. .................................................. ............ 82 Data Integrity ................................... .................................................. ..................... 85 IV Contents CHAPTER 5. FORM AS A MEANS OF ENTRYING AND EDITING DATA ................ ........................................ 89 Creating a form using the wizard .... .................................................. ....................... 90 Starting the form ........................ .................................................. ........................................... 97 Shape Objects ... .................................................. .................................................. .......... 97 Actions performed with form objects ................................. .............................. 101 Changing the sequence of entering information in the form fields ............ .............. 105 CHAPTER 6. FORM DESIGNER .............................. ....................................... 109 Window form constructor ................................................ ................................................ 109 Creation forms ................................................. .................................................. ........... 113 Configuring Shape Parameters ................................... .................................................. ... 114 Form Environment ........................................... .................................................. .... 116 Procedure for setting shape parameters ............................. 122 Placing objects in the shape ... .................................................. ................................ 123 CHAPTER 7. CREATING AND PRINTING REPORTS .......... ........................................... 157 What is a report ... .................................................. .................................................. .......... 157 Recommendations for creating a report ................................... ......... .................................... 157 Reporting tools .......... .................................................. .................................. 158 Using the Wizard to Create a Single Table Report ......... .......................... 158 Viewing the prepared report .................... .................................................. ........... 168 Print report .................................... ............................................ .................................... 169 CHAPTER 8. CREATING A REPORT USING THE REPORT DESIGNER .... .................................................. ......... 173 Report Designer Window ..................................... .................................................. ..... 173 Using the Quick Report Command to Place Fields .................................... 175 Setting the environment for the report .............................................. ................................. 179 Properties of report objects ............. .................................................. ................................. 182 Placing objects in the report ............ .................................................. ......................... 188 Adding Title and Totals Areas to the Report ................. ........................................ 200 Creating a simple report ...... .................................................. ....................................... 201 Create a report in a free th form ................................................ ............................. 203 Creating a tabular report ................. .................................................. ........................ 205 Grouping data in the report ..................... .................................................. .................. 207 Using variables in the report ........................... .................................................. 211 Report Page Layout .............................................. ................................................. 213 Multi-column report ................................................ ................................................. 215 CHAPTER 9. DATABASE INQUIRIES ........................................... .................. 217 Query Builder ............................. .................................................. ...................... 218 Formation of the list of fields of the resulting query table ..................... ........ .. 221 Order By Tab of the Query Builder .......................................... ............................ 225 Setting conditions for selecting records ................ .................................................. .......... 227 Multi-table queries ..................................... .................................................. ........ 233 Grouping of request fields ...................................... .................................................. ... ... 237 Changing the names of fields in the request ......................................... ......................... 241 Table of Contents V CHAPTER 10. CROSS TABLES AND DIAGRAMS ............... ............... 243 Cross tables ................................ .................................................. .................. 243 Data export ............................. .................................................. ................................ 254 Building diagrams ............... .................................................. ..................................... 254 CHAPTER 11. APPLICATIONS MENU ....... .................................................. ......... 261 Preparing to create a menu .................................... .................................................. .. 261 Actions required to create a menu ......................................... ....................... 262 Launching the menu builder ....................... ............................................ .......................... 262 Menu creation ..................... .................................................. .......................................... 264 Saving, generating and launching menus. .................................................. ...................... 278 Creating a pop-up menu ........................ .................................................. ............ 279 CHAPTER 12. CREATING THE APP HELP SYSTEM ............... 281 Status bar ............ .................................................. ............................................... 281 Using the Dialogue windows ................................................. .................................. 282 Creating an HTML Help System ......... ............................................... 285 Using the reference systems in applications ............................................... ... 293 CHAPTER 13. PROJECT MANAGEMENT AND CREATING AN APPLICATION ......... 297 Defining window properties project ................................................. .............................. 297 Setting project parameters ................ .................................................. ......................... 299 Installing the main program of the project .................... .................................................. 302 Using the Exclude Option .............................................. .......................................... 303 Clearing a project from deleted files. .................................................. ...................... 303 Building the project ......................... .................................................. .............................. 303 Visual FoxPro Component Gallery ............... .................................................. .............. 306 CHAPTER 14. VERIFICITY CONDITIONS, STORED PROCEDURES, TRIGGERS, REPRESENTATION OF DATA ...................... ................ 315 Conditions for the validity of data entry at the record level .......................... ................. 315 Conditions for the validity of data entry at the table field level ........................ ........ 323 Using Data Views ...................................... ................................... 325 CHAPTER 15. ADVANCED DATA ENTRY FACILITIES ....... ....................... 337 Displaying data in a tabular form ................... ...................................... 337 Creating a Tabbed Form ....... ............................... .................................................. 356 Form Set ............................................... .................................................. ..................... 360 Timer ........................... .................................................. .................................................. 361 Adding data to the list ............................................. ............................................ 364 CHAPTER 16. CLASS LIBRARIES AND ACTIVEX COMPONENTS ................. 367 Using Class Libraries ......................... .................................................. ..... 367 Using ActiveX-components in the form ...................................... ....................... 374 Using the Object Browser ....................... .................................................. ........ 390 CHAPTER 17. ADVANCED REPORTING TOOLS ..................... 395 Using Data Views in Reports ....... ..................... ............................. 395 Labels ................... .................................................. .................................................. .... 396 Using a one-to-many relationship in reports .................................. .......... 404 VI Table of Contents CHAPTER 18. ADVANCED FACTORS OF DATA ... 409 Output of query results ... .................................................. ..................................... .... 409 Saving query results in HTML format ....................................... .............. 412 Using the Select command in programs .............................. ................................. 414 CHAPTER 19. VISUAL OBJECT-ORIENTED PROGRAMMING ........ .................................................. ........ 419 Using classes ....................................... .................................................. .......... 419 Using nested objects .................................... ......................................... 434 Custom Classes ...... .................................................. ........................................ 437 Viewing information about a class and defining an icon for it designations .......... 447 Formation of the list of libraries used in constructors of forms and classes ............................ .................................................. ...... 450 Create User-Based Forms classes ................................................ .. 450 Using a Form to Create a Class .......................................... ....................... 454 Class Browser ....................... .................................................. ............................ 455 Creating a toolbar .................. .................................................. ................. 458 CHAPTER 20. MULTIPLAYER WORK IN THE LOCAL NETWORK ........................ ............................................... 463 Locking types .................................................. .................................................. ......... 463 Automatic blocking ...................................... .................................................. .... 463 Full table lock and change lock ... ....... 465 Locking a table ........................................ ...................................... .......................... 466 Locking records ..................... .................................................. .................................. 466 Unlocking tables and records .......... .................................................. ............... 468 Data sessions .............................. .................................................. .............. 469 Using buffers ................................. ...................... ........................................... 470 Using transactions ... .................................................. ....................................... 474 CHAPTER 21. LINKING AND IMPLEMENTATION OF OBJECTS, EXPORT AND IMPORT OF DATA ................................................ ..................... 475 Visual FoxPro and OLE Objects ...................... .................................................. ................. 475 Linking an OLE Object ............................ .................................................. .................. 481 Editing an OLE Object ........................... .................................................. ............ 484 Deleting an OLE Object ................................. .................................................. ................. 484 Using Object-Oriented Programming ........................... ... 484 Transferring Data from Visual FoxPro to Other Applications ...................................... ..... 486 Import Data oops ................................................. .................................................. ............. 488 Using data from Visual FoxPro in Microsoft Word ............................ ............. 491 CHAPTER 22. REMOTE DATA REPRESENTATIONS .............................. ..... 497 Defining an ODBC Data Source ........................................ ................................ 497 Named Connection ............... .................................................. .............................. 500 Connection constructor ................. .................................................. ............................. 500 Configuring Remote Views and Connections in the Options Dialog Box .......... .................................................. ................................... 503 Creating a Remote Data View .......... .................................................. ... 505 Table of Contents VII Shared Connections ... .................................................. .................... 513 Combination in the presentation of local and remote data ...................... ... 514 Customizing a View Using a Database Dictionary ... 516 CHAPTER 23. DATA TRANSFER FROM VISUAL FOXPRO TO CLIENT-SERVER PLATFORM ..................................... .......... 519 Using the Growth Wizard to Migrate Data to a SQL Server Database ............. .................................................. ................................. 519 CHAPTER 24. PUBLICATION OF DATA ON THE WEB-SERVER ....... .......................... 531 Web Publishing Wizard .................... .................................................. ................................ 531 Configuring Web Page Settings Using the Wizard ......... ............................... 535 Creating a Web page .............. .................................................. ................................. 539 Editing the created Web page ........... .................................................. ...... 543 CHAPTER 25. CONFIGURING VISUAL FOXPRO PARAMETERS ................................ 545 Window Tab Parameters Options ................................................. ................................... 546 APPENDIX. INSTALLING VISUAL FOXPRO .............................................. 573 System requirements ............................................... .................................................. ..... 573 Installing Visual FoxPro ......................................... .................................................. ....... 573 Customizing Visual FoxPro ....................................... .................................................. ........ 575 GLOSSARY ........................................ .................................................. ........... 579 INDEX .................................... ........................................ 589 VIII CONTENTS INTRODUCTION In recent years, rumors have sprung up from time to time that Microsoft will no longer support the Visual FoxPro software product. But again they turn out to be the intrigues of ill-wishers. And the next new version of Visual FoxPro 9.0 is a direct confirmation of this. Despite the emergence of new database management systems, Visual FoxPro continues to be one of the most popular programs in this area. This is primarily due to the fact that when creating new versions, Microsoft maintains compatibility with previous versions. Therefore, the applications you create can be used in the future. Visual FoxPro implements all the attributes of relational database management systems. The database maintains data integrity using primary keys and relationships between tables. You can use triggers and stored procedures to handle events for adding, deleting, or modifying table records using the database itself. Visual FoxPro is an object-oriented, visual-programmable, event-driven language that fully meets the new requirements for modern software design and implementation tools. Visual FoxPro can be used by users of different skill levels. If you are just starting to master Visual FoxPro and you need to develop a simple application as soon as possible, the wizards for creating databases, tables, applications, forms, reports, etc. will help you. For the development of large and complex projects, appropriate designers and an object-oriented language are used , which allows you not only to use base Visual FoxPro classes and external libraries, but also to create custom classes. This book is of interest both for beginners familiar with Visual FoxPro 9.0, and for those with experience with this system of developers. The book sequentially describes the entire process of creating complete applications: creating a database and its tables, designing forms for entering and viewing data, creating queries and reports, as well as other means of displaying and processing database information. The book contains a large number of illustrations that will help you get acquainted with the material presented in it. 2 INTRODUCTION HOW TO USE A BOOK If you are just starting to learn Visual FoxPro, the chapter order suggested will allow you to go from easy to difficult to learn this software. If you are familiar with Visual FoxPro, you do not need to read the book from start to finish. In the table of contents of the book, you can see which chapters are of most interest to you, and study only them. You can learn a lot by just skimming through the book. It has specially highlighted moments that will catch your eye when you scroll through it. How to build a book The book assumes a sequential study of material from simple to complex. Chapters 1 and 2 of the book are introductory. You will learn how to start Visual FoxPro, how to get help in it, get acquainted with the elements of the main program window and what is new in Visual FoxPro 9.0 compared to previous versions. In Chapter 3, you will learn about the project, which is a means of combining elements of an application. After completing Chapter 4, you will learn how to create a database, its tables, indexes, relationships between tables, and determine data integrity conditions. Chapters 5 and 6 explore how to create forms for entering and editing data using a wizard and form designer. Chapters 7 and 8 focus on designing simple reports. After reading Chapter 9, you can create a query of any complexity. Chapter 10 introduces you to creating crosstabs and charts. The application uses a menu to launch forms, reports and programs. Chapter 11 talks about creating such an application menu. After reviewing the first eleven chapters and analyzing the examples presented to your attention, you can create applications yourself. The following chapters build on the knowledge gained in the first chapters and are devoted to advanced tools for creating forms, queries, reports. Chapter 12 discusses how to develop an effective HTML help system for your application. Chapter 13 discusses some additional project management issues, including creating an executable (exe) file. Chapters 14 through 18 discuss advanced database management, multi-tabular forms and reports, and the use of ActiveX components in forms. Chapter 19 introduces you to the object-oriented approach to building database applications. You will learn how to create classes and objects based on them. Chapter 20 is devoted to the work of Visual FoxPro on a local network. INTRODUCTION 3 Visual FoxPro is not an isolated system and can effectively interact with other Windows applications. After reading Chapter 21, you will learn how to work with compound objects (OLE), export and import data. You will learn how to install the ODBC driver, how to create a remote data view and configure its parameters in Chapter 22. Chapter 23 introduces you to porting data from Visual FoxPro to a client / server platform using the Growth Wizard. Visual FoxPro has the ability to generate a Web page using the information contained in the database. This is discussed in Chapter 24. To work effectively with Visual FoxPro, you use the parameters that are discussed in the last chapter of the book. The appendix walks you through installing Visual FoxPro 9.0. The book also contains a glossary describing Visual FoxPro terms. Special Elements of the Book There are many special inserts in the book that are highlighted in a special way. They contain additional information to make it easier to read and find information: NOTE Notes refer to the consequences of certain actions. NOTE Tips provide some tips you need to know to get the most out of Visual FoxPro. NOTICE Warnings should help you avoid problems. They tell you what to fear and what to do to avoid mistakes. The book uses different types of fonts: new terms are in italics; the text that you must enter from the keyboard is in bold italic; menu commands, names of buttons, tabs, options, check boxes, dialog boxes, areas, etc. are in bold; names of functions, properties, methods, databases, tables, table fields are in monospaced font. The two keys connected by a plus sign is a key combination. Press the first key and, without releasing it, press the second. Then release both. The authors express their gratitude to the publishing house "BHV-Petersburg" for long-term fruitful cooperation and assistance in the preparation and writing of the book. 4 Introduction Chapter 1 About Visual FoxPro The changes taking place in our country in recent years could not but affect the fields of informatics and computer technology. Until ten years ago, working with databases was the lot of professional programmers. The systems themselves were not designed for the common user. The main consumer of such systems was the military-industrial complex. With the emergence of banks, joint-stock companies, private companies, databases have found wider application. People understand that information is money. Losing it or getting it late can be costly. This can explain the rapid growth of information technology and the rapid development of database management systems (DBMS). Relational Databases The first database management systems emerged in the mid-1960s and supported a hierarchical data model in which parent / child relationships existed between records. Within a short time, network databases were developed based on a much more complex network model. Each of these models had advantages and disadvantages that played a key role in the development of the relational model. In 1970, an article by IBM researcher Dr. E. F. Codd on the relational data model revolutionized the way we store and process information. The first relational databases were developed on the basis of this model in the seventies of the last century, and now they are considered as the standard for modern commercial DBMS. In relational databases, all information is summarized in tables, the rows and columns of which are called records and fields, respectively. These tables were called relations1, so the model was called relational. Entries in tables are not repeated. Their uniqueness is provided by a primary key containing 1 Relationship - a mathematical term from set theory, which formed the basis of the relational data model. In English, the word "relation" corresponds to the word "relation", hence the name "relation". - Ed. Chapter 1 6 is a set of fields that uniquely identify a record. To quickly search for information in the database, indexes are created on one or more fields of the table. Index values are stored in an ordered manner and contain references to table records. Primary and foreign keys are used to automatically maintain the integrity of related data in different tables. To fetch data from multiple related tables, the values of one or more of the matching fields are used. For example, the registration table is long-distance calls can contain the following information: Íîìåð çàêàçà Êîä óñëóãè Íîìåð òåëåôîíà Äàòà ðàçãîâîðà Êîä ãîðîäà Ïðîäîëæèòåëüíîñòü ðàçãîâîðà Ñòîèìîñòü Ïðèìå ÷ àíèå Records of long-distance calls are recorded in the registration book, as a table in chronological order (Figure 1.1.). Each line has the same structure and consists of eight fields. In this example, these are the following fields: Order number, Service code, Phone number, Call date, City code, Call duration, Cost. Fig. 1.1. LOGGING INTERMEDIATE SPOTS BY ARRAY In relational databases, fields can have different data types (numeric, string, date type, etc.), but for each record, the data type of the field remains the same. One of the important advantages of the database is the fast retrieval of the information stored in it. Using the telephone address book, in which the data is sorted by last name, you can find a phone number by the last name of its owner. However, if the long distance book entries are ordered chronologically, you will have to spend a significant amount of time getting Visual FoxPro 7 a list of customers who have ordered a call to a specific city, or figuring out which area the most profitable subscribers live in. telephone company with long conversations. Computer databases come to the rescue. They, despite the huge amount of information stored in them, provide a high speed of searching for the necessary information. In such databases, the user can search for any parameter of interest. Moreover, computer databases are very compact. A database containing several thousand records can fit on one floppy disk. Database management systems are used to create a database, change its structure, edit and retrieve data. Modern relational database management systems contain: a set of tools for creating tables and relationships between related tables; database administration tools; developed user interface that allows you to access information stored in the database; development tools for applications using databases. In fig. 1.2 shows an example of long distance telephone call accounting using two relational database tables in Visual FoxPro. Fig. 1.2. Reads Intermediate Phone Speakers Using the Television Tables Chapter 1 8 Fig. 1.3. Reading in the standard video, containing information about the customers of the telephone company Fig. 1.4. Information Writing, Reference Information With Visual FoxPro 9 Fig. 1.5. Graphical presentation of information about the number of hardware. For example, you can get information about all long-distance calls of a certain customer for any period of time; print the entire table or just selected records and fields in various formats. For example, in Fig. 1.3 shows a tabular report containing the addresses of the telephone company customers. In fig. 1.4 shows one of the variants of a newsletter containing the names and surnames of clients from the same table; display database information graphically. For example, in Fig. 1.5 data on the number of long-distance calls for clients are displayed in the form of a diagram; carry out the necessary calculations when generating reports and selecting data from tables. Currently, there are more than ten popular DBMS for personal computers. Traditionally, one of the most widespread in Russia and the CIS countries is the Visual FoxPro DBMS, the new version of which, Visual FoxPro 9.0, contains additions and improvements that expand the capabilities of the system. 10 Chapter 1 Visual FoxPro Objects Visual FoxPro consists of individual components that are used to store, display, and edit information. In Visual FoxPro, all information is stored in a database, which consists of tables, relationships between tables, indexes, triggers, and stored procedures. Each table has a unique name and is stored in a separate file, the name of which is the same as the name of the table. The created file has the dbf extension. Each table you create can have indexes associated with it, which are used to organize data and quickly find the records you need, and one table can have multiple indexes. Separate files are used to store the values of the Memo and General fields. Memo fields of tables contain textual information, and fields of type General are used, as a rule, to store binary information and data of other applications running in the Windows environment. Visual FoxPro implements triggers that allow you to centrally process events that occur when any changes to the database are made. You can also create stored procedures that are part of the database and can be used to describe tables, validate input data, define default values, and so on. Data views are an extremely convenient and useful means of accessing a database. Data views allow you to combine table data and display it in a more convenient way. You can select only the table fields you are interested in, combine multiple fields into one field, calculate totals, and specify new table field names. Typically, the number of views in a database far outnumbers the number of tables. As the database is used, their number is constantly growing. In many information systems, access to data, including viewing, adding and editing, is carried out only through the use of data views. This approach allows for flexible control over access to information. When using views to select data in forms, reports, when creating queries, and in programs, the same rules apply as for tables. Editing the data included in the presentation is possible only under certain conditions. For example, if it is created based on only one table. Forms, reports, queries and programs are used to display and edit data. Designers are used to create forms, reports, and queries. Therefore, these components are often referred to as design objects. Forms and reports are composite objects because they are composed of smaller objects (such as fields, buttons, charts, frames, OLE components, etc.) which are called interface objects. Forms are used to view or enter data into tables. Data can be entered directly into tables, but using a form is a faster and more efficient way to enter. The form contains some or all of the table fields in which you enter information. You can use the Form Builder or the Form Designer to create forms. The Form Wizard contains a number of templates that define the relationship between the faces that are placed on the form in the Visual FoxPro 11 tabs, the way the data is displayed, and the order in which the fields are placed. A form designer is used to create complex shapes. Reports are used to print the information contained in the database. Examples of reports are price list of goods, list of buyers, turnover list. As a rule, reports are created in the event that information needs to be transmitted to someone in hard copy. To create reports in Visual FoxPro, just like for forms, you use a wizard and a report designer. Using the Report Wizard, you can quickly create your own report based on the templates available. Using the Report Designer allows you to create reports of arbitrary complexity, including multi-level data grouping and the placement of calculated fields. Queries are a means of fetching data from one or more tables. In Visual FoxPro, you can use either the Query Designer or the specialized Structured Query Language (SQL) to create a query. Query results can be displayed in a form, displayed as reports and charts, or saved in a table you specify. Programs written in the Visual FoxPro language are object-oriented. With the help of them, you process events in the form, create objects, perform various calculations, manage the database. For convenience, you can combine programs into libraries. To create forms in Visual FoxPro, you can use not only base classes, but also create your own. For example, you can define a form class that has a specific background color and a standard set of buttons for manipulating data. To standardize development, it is helpful to have one or more custom classes for each base class. Classes created in Visual FoxPro are stored in class libraries. To combine the components of the created application, a project is used, which includes all the components listed above. Using a project simplifies application development and maintenance. Each component is stored in a separate file, and the names of the files containing the main components you specify yourself, and the names of the files containing the objects associated with the table coincide with the name of the table. Based on the type of object it contains, Visual FoxPro automatically assigns an extension to each file to help identify the object. The list of file extensions is given in table. 1.1. Table 1.1. Ðàñøèðåíèÿ èìåí ôàéëîâ îáúåêòîâ Visual FoxPro Íàèìåíîâàíèå îáúåêòà Ðàñøèðåíèÿ Ïðîåêò prj, fpc, cat, pjx, pjt Áàçà äàííûõ dbc Òàáëèöà Visual FoxPro dbf Ñîñòàâíîé èíäåêñíûé ôàéë cdx Memo-ïîëå è ïîëå òèïà General frt Ãëàâà January 12 Òàáëèöà 1.1 (îêîí ÷ àíèå) Íàèìåíîâàíèå îáúåêòà Ðàñøèðåíèÿ Ôîðìà scx Çàïðîñ qpr Îò ÷ åò frx, frm Ïî ÷ òîâàÿ íàêëåéêà lbx, lbl ìåíþ mnx áèáëèîòåêà êëàññà vcx Ïðîãðàììà, áèáëèîòåêà ïðîãðàìì, òåêñò ìåíþ, prg, fxp, mpr, qpr òåêñò çàïðîñà Ðèñóíîê bmp, jpg, gif, ico, dib , cur, ani Recording wav This New Arrival in Visual FoxPro 9.0 Visual FoxPro is an ever-evolving system. Compared to the previous version, Visual FoxPro 9.0 takes one more step in expanding the system's functionality, improving the existing tools related to the development environment interface and error handling, adding new commands, base classes and functions, and expanding the existing ones. The new version has all the capabilities for working with XML Web services, as well as improved compatibility with Microsoft Visual Studio .NET and Microsoft SQL Server 2000. Visual FoxPro has extended table designer tools. New data types can be used for table fields: Binary Blob and Text Varbinary. The Blob data type is used for structures containing information about a data block. It is used to store binary information of any type, for example, ASCII characters, executable files, byte streams. The Varbinary data type contains hexadecimal values. It is similar to the Character type, but for data of this type, empty spaces are not filled with insignificant information. A new type of index, Binary, has been introduced, which is based on Boolean expressions and is used for both free tables and database tables. This index takes up significantly less space and therefore improves the speed of index use. Objects placed on the form have new properties. Let's consider the most interesting ones. The Anchor property sets the absolute and relative positions and sizes of the object relative to all four sides of the container object, solving the problem of automatically positioning and resizing objects on the form when it is resized when the Resize event occurs. About Visual FoxPro 13 The Rotation property of Label, Line, and Shape objects allows you to display labels for large objects of the EditBox class as text flowing from bottom to top. The AutoComplection property of the TextBox object allows you to remember the values entered in the field and, when you enter a new value, to show this list for easier input. This property is useful when entering data in a field that has a small set of options. The AutoHideScrollBar property of the ListBox allows you to hide the scroll bar when all rows are visible and show it back when not all rows fit in the ListBox. The PictureMargin and PictureSpacing properties of the CommandButton, OptionButton, and CheckBox objects control the position of the image relative to the edge and text of the object. The MousePointer property for the columns (Column object) and headers (Header object) of the Grid object at the stage of class or form editing sets the required form of the mouse pointer when it enters the field of this object. The SET PATH TO command now has an ADDITIVE property that allows you to add new paths to existing ones, and the length of all paths has increased from 1024 to 4096. In the Project Manager, you can now execute the Modify command when you select a class library, and not a separate class of this library. Visual FoxPro 9.0 launches the Class Browser with the selected class library. Developers will be pleased with the changes in the report designer. Configuring all objects (location of an object in the report strip, style of design, printing conditions, protection against alteration) placed in the report is carried out using the properties dialog box. All parameters of the report itself (page layout, adding header and total areas to the report, grouping data, setting report variables, saving the report as a class) are also set using the Report Properties dialog box. The changes have been made to custom properties and methods. When you create new properties and methods, you can assign default / initial values to them. Enhanced options for customizing Visual FoxPro, carried out from the Options dialog box, which is opened by the Options command from the Tools menu. Enlarged the list of file groups defined by the File Locations tab. The View tab now has a List display count that lets you set the maximum number of list items to display when using IntelliSense. The set of parameters set on the Reports tab has been significantly expanded. 14 Chapter 1 Chapter 2 Getting Started with Visual FoxPro You are getting started with Visual FoxPro 9.0. Many of the things you will have to work with (menus, toolbars, dialog boxes) will seem familiar because they are specific to the Windows environment. Starting Visual FoxPro To start the program from the Windows main menu, follow these steps: 1. Click the Start button located at the bottom of the screen. 2. In the opened Windows main menu, select the Programs command. The menu for this command appears. 3. Select the Microsoft Visual FoxPro 9.0 command from the menu. The main window of Visual FoxPro 9.0 will open on the screen (Fig. 2.1). TIP To launch Visual FoxPro 9.0 faster, you can create a shortcut on your desktop and assign keyboard shortcuts to it. Then it will be enough to press the specified key combination in any Windows window, and the program will start. In addition, for the convenience of launching the application, you can use the Windows Quick Launch bar by placing the Visual FoxPro program icon on it. Visual FoxPro Main Window 2.1 shows the main window of Visual FoxPro as it looks after starting the program. It has seven main objects: the window title, menu bar, toolbar, status bar, work area, Command window, and the Task Pane Manager dialog box. The title bar is at the top of the main window and contains three objects: a copy of the Visual FoxPro program icon, the title of the main window, and icons to control that window. The menu bar contains a hierarchical Visual FoxPro menu. The list of menu items depends on the type of active window. 16 Chapter 2 Fig. 2.1. Visual FoxPro 9.0 Main Window Visual FoxPro provides the user with a wide variety of toolbars for working with databases, forms, reports, and queries. These toolbars contain a set of buttons, and this set depends on the purpose of the particular toolbar. After starting Visual FoxPro, the standard toolbar is displayed on the screen. At the bottom of the main window there is a status bar, which displays information about the current state of the active window, a short description of the selected button on the toolbar or menu item. The information displayed in the status bar depends on the type of active window. For example, in the form designer window, the status bar displays the name of the active form object, and when viewing the table in Browse mode, the name of the open table is displayed on the left side of the status bar, and the number of the current record and the operating mode indicator in the middle of the status bar. In Visual FoxPro 9.0, the main window displays the Task Pane Manager by default. It contains a list of recently opened projects and databases, help launch commands and wizards for creating a database and project, examples that you can use in development, and useful links to sites on the Internet. Getting Started with Visual FoxPro 17 As you work, the main Visual FoxPro window opens windows for designers of forms, reports, queries, projects, and other windows. All of them are children of the main window and are closed when it is closed. In addition, if you did not close the project window you were working with when exiting Visual FoxPro, it will open by default in the main window the next time you start the program. System menus and system buttons The title of the main window contains a small copy of the program icon, the text "Microsoft Visual FoxPro" and buttons to control the size of the main window. When you click on the icon of the icon, a system menu opens, containing commands for moving and resizing the main window. Table 2.1 shows the commands available from the system menu. Table 2.1. Íàçíà ÷ åíèå êîìàíä ñèñòåìíîãî ìåíþ Êîìàíäà Íàçíà ÷ åíèå Âîññòàíîâèòü Âîññòàíàâëèâàåò ïðåäûäóùèé ðàçìåð îêíà ïîñëå ìèíèìèçàöèè èëè ìàêñèìèçàöèè Ïåðåìåñòèòü Àêòèâèçèðóåò ãëàâíîå îêíî Visual FoxPro è ïîçâîëÿåò ïåðåìåùàòü åãî ñ ïîìîùüþ êëàâèø ïåðåìåùåíèÿ êóðñîðà Ðàçìåð Àêòèâèçèðóåò ãëàâíîå îêíî Visual FoxPro è ïîçâîëÿåò èçìåíÿòü åãî ðàçìåðû ñ ïîìîùüþ êëàâèø ïåðåìåùåíèÿ êóðñîðà Ñâåðíóòü Ñâåðòûâàåò ãëàâíîå îêíî FoxPro äî ðàçìåðà êíîïêè è ïîìåùàåò åå íà ïàíåëü çàäà ÷ windows Ðàçâåðíóòü Ðàçâåðòûâàåò ãëàâíîå îêíî Visual FoxPro âî âåñü ýêðàí Çàêðûòü Çàêðûâàåò ãëàâíîå îêíî ïðîãðàììû Visual FoxPro TIP to quickly close the Visual FoxPro program, double-click on a small copy of the application icon in the header of the main window ... To quickly restore / maximize the main window, double-click on the title bar. The Microsoft Visual FoxPro text of the main window title can be easily changed, if necessary, by assigning any other name to the main Visual FoxPro window, or by removing the name altogether. To do this, enter the following command in the command window: MODIFY WINDOW SCREEN TITLE "(! LANG: New title of the main window"
или
_SCREEN.caption = "Новый заголовок главного окна"
В правой стороне заголовка расположены кнопки управления окном. Их назначение
описано в табл. 2.2.
18
Ãëàâà 2
Òàáëèöà 2.2. Íàçíà÷åíèå êíîïîê óïðàâëåíèÿ îêíîì
Êíîïêà
Íàçâàíèå
Íàçíà÷åíèå
Ñâåðíóòü
Ñâîðà÷èâàåò ãëàâíîå îêíî FoxPro äî ðàçìåðà êíîïêè è ïîìåùàåò åå íà ïàíåëü çàäà÷ Windows
Âîññòàíîâèòü
îáðàòíî
Óìåíüøàåò ðàçìåð ðàçâåðíóòîãî îêíà, ïîçâîëÿÿ â äàëüíåéøåì èçìåíÿòü åãî
Ðàçâåðíóòü
Ðàçâåðòûâàåò ãëàâíîå îêíî Visual FoxPro âî âåñü ýêðàí
Çàêðûòü
Çàêðûâàåò ãëàâíîå îêíî Visual FoxPro, òåì ñàìûì ïðåêðàùàÿ
ðàáîòó ïðîãðàììû
Çíàêîìñòâî ñî ñòàíäàðòíîé ïàíåëüþ
èíñòðóìåíòîâ Visual FoxPro
В Visual FoxPro имеется большое количество панелей инструментов, используемых
при создании форм, отчетов и запросов. Подробно они будут рассмотрены в соответствующих главах. Сначала изучим стандартную панель инструментов (рис. 2.2),
которая используется во всех режимах работы.
Ðèñ. 2.2. Ñòàíäàðòíàÿ ïàíåëü èíñòðóìåíòîâ Visual FoxPro
Назначение кнопок стандартной панели инструментов описано в табл. 2.3.
Òàáëèöà 2.3. Íàçíà÷åíèå êíîïîê ñòàíäàðòíîé ïàíåëè èíñòðóìåíòîâ
Êíîïêà
Íàçâàíèå
Íàçíà÷åíèå
New (Íîâûé)
Ïîçâîëÿåò ñîçäàòü íîâûé ôàéë (ïðîåêò, áàçó äàííûõ,
òàáëèöó, çàïðîñ, ôîðìó, îò÷åò, êëàññ)
Open (Îòêðûòü)
Îòêðûâàåò ñóùåñòâóþùèé ôàéë
Save (Ñîõðàíèòü)
Ñîõðàíÿåò îòêðûòûé ôàéë
Print One Copy
(Ïå÷àòàòü îäíó êîïèþ)
Ïå÷àòàåò ñîäåðæèìîå àêòèâíîãî îêíà
Print Preview
(Ïðîñìîòð ïå÷àòè)
Îòêðûâàåò îêíî ïðåäâàðèòåëüíîãî ïðîñìîòðà ïå÷àòàåìîãî äîêóìåíòà
Cut (Âûðåçàòü)
Óäàëÿåò âûäåëåííûé òåêñò èëè âûäåëåííûå îáúåêòû è
ïîìåùàåò èõ â áóôåð
Copy (Êîïèðîâàòü)
Êîïèðóåò â áóôåð âûäåëåííûé òåêñò èëè âûäåëåííûå
îáúåêòû, íå óäàëÿÿ èõ
Paste (Âñòàâèòü)
Âñòàâëÿåò ñîäåðæèìîå áóôåðà. Äåéñòâèå ýòîé êíîïêè
çàâèñèò îò òîãî, â êàêîì èç ðåæèìîâ âû ðàáîòàåòå
Íà÷àëî ðàáîòû ñ Visual FoxPro
19
Òàáëèöà 2.3 (îêîí÷àíèå)
Êíîïêà
Íàçâàíèå
Íàçíà÷åíèå
Undo (Îòìåíèòü)
Îòìåíÿåò âûïîëíåííûå äåéñòâèÿ
Redo (Âîññòàíîâèòü)
Âîññòàíàâëèâàåò îòìåíåííûå äåéñòâèÿ
Run (Âûïîëíèòü)
Çàïóñêàåò íà âûïîëíåíèå
Modify Form
(Ìîäèôèöèðîâàòü ôîðìó)
Ïîçâîëÿåò ìîäèôèöèðîâàòü SÑX-ôàéë, ñâÿçàííûé
ñ äàííîé ôîðìîé
Databases
(Áàçû äàííûõ)
Ñîäåðæèò ñïèñîê îòêðûòûõ áàç äàííûõ
Command Window
(Êîìàíäíîå îêíî)
Îòêðûâàåò êîìàíäíîå îêíî
Data Session Window
(Îêíî ñåàíñà äàííûõ)
Îòêðûâàåò îêíî Data Session
Properties Window
(Îêíî ñâîéñòâ)
Îòêðûâàåò îêíî Properties (Ñâîéñòâà), èñïîëüçóåìîå äëÿ íàñòðîéêè ñâîéñòâ
Document View Window
(Îêíî ïðîñìîòðà
äîêóìåíòà)
Îòêðûâàåò îêíî Document View (Ïðîñìîòð äîêóìåíòà), â êîòîðîì îòîáðàæàåòñÿ ñïèñîê ïðîöåäóð,
ôóíêöèé îòêðûòîé â îêíå ðåäàêòîðà ïðîãðàììû
Class Browser
(Îáçîð êëàññîâ)
Îòêðûâàåò îêíî Class Browser (Îáçîð êëàññîâ),
ïðåäíàçíà÷åííîå äëÿ ðàáîòû ñ êëàññàìè
Object Browser
(Îáçîð îáúåêòîâ)
Îòêðûâàåò îêíî Object Browser (Îáçîð îáúåêòîâ),
ïîçâîëÿþùåå ïðîñìàòðèâàòü êëàññû, ñâîéñòâà,
ìåòîäû, ñîáûòèÿ è êîíñòàíòû âûáðàííûõ áèáëèîòåê
Task Pane (Ïàíåëü çàäà÷)
Îòêðûâàåò îêíî Task Pane Manager (Ìåíåäæåð
ïàíåëè çàäà÷)
Toolbox (Èíñòðóìåíòàðèé) Îòêðûâàåò îêíî Toolbox (Èíñòðóìåíòàðèé), ñîäåðæàùåå ýëåìåíòû, êîòîðûå èñïîëüçîâàëèñü
ðàçðàáîò÷èêîì ïðè ñîçäàíèè ïðèëîæåíèÿ
ЗАМЕЧАНИЕ
Если по внешнему виду кнопки вы не можете определить ее назначение, установите указатель мыши на кнопку. При этом под курсором появится всплывающая подсказка с ее наименованием, а в левой части строки состояния будет выведено краткое описание указанной
кнопки.
По умолчанию в главном окне программы Visual FoxPro всегда присутствует стандартная панель инструментов. Если она не отображается на экране, выполните следующие действия:
1. Выберите в меню View (Вид) команду Toolbars (Панели инструментов). Откроется
диалоговое окно Toolbars (рис. 2.3), в котором расположен список всех панелей
инструментов программы Visual FoxPro.
20
Ãëàâà 2
2. Установите флажки слева от наименований тех панелей, которые необходимо
разместить в главном окне.
3. Нажмите кнопку OK.
Используя флажки, расположенные в нижней части диалогового окна Toolbars (Панели инструментов), можно изменить вид кнопок панелей инструментов. Назначение этих флажков описано в табл. 2.4.
Òàáëèöà 2.4. Íàçíà÷åíèå ôëàæêîâ äèàëîãîâîãî îêíà Toolbars
Óñòàíîâêà ôëàæêà
Íàçíà÷åíèå
Color buttons (Öâåòíûå êíîïêè)
Êíîïêè íà ïàíåëè èíñòðóìåíòîâ ñòàíîâÿòñÿ öâåòíûìè
Large buttons (Áîëüøèå êíîïêè)
Óâåëè÷èâàåòñÿ ðàçìåð êíîïîê
ToolTips (Ïîäñêàçêà)
Âûâîäèòñÿ êðàòêîå îïèñàíèå êíîïêè ïðè óñòàíîâêå êóðñîðà íà íåå
Ðèñ. 2.3. Äèàëîãîâîå îêíî Toolbars
После установки Visual FoxPro стандартная панель инструментов размещается
в верхней части главного окна, но она, как и все остальные панели инструментов, может перемещаться в любое место экрана. Для этого нужно установить курсор
мыши в любое свободное от кнопок место на панели инструментов, нажать кнопку мыши и, не отпуская ее, переместить панель на новое место. Если поместить
панель инструментов не по краю главного окна Visual FoxPro, то можно изменять ее
размер (рис. 2.4).
Íà÷àëî ðàáîòû ñ Visual FoxPro
21
Ðèñ. 2.4. Ïàíåëü èíñòðóìåíòîâ ìîæíî ðàñïîëîæèòü
â ëþáîì ìåñòå ãëàâíîãî îêíà
Êðàòêèé îáçîð ìåíþ Visual FoxPro
При работе с Visual FoxPro можно использовать как кнопки панели инструментов,
так и строку меню, все команды которого являются иерархическими. При выборе
определенной команды открывается ее подменю.
При отсутствии в главном окне Visual FoxPro других открытых окон, строка меню
содержит пункты File (Файл), Edit (Правка), View (Вид), Tools (Инструменты),
Program (Программа), Window (Окно) и Help (Справка). При открытии окон в меню
добавляются команды, применимые только к объектам данного окна. Например,
при работе с таблицами в главное меню добавляется пункт меню Table (Таблица),
при открытии на экране формы в меню появляется пункт Form (Форма).
ЗАМЕЧАНИЕ
При выборе команды в строке состояния появляется ее краткое описание.
22
Ãëàâà 2
Âûïîëíåíèå êîìàíä ìåíþ
Выполнение команд меню в Visual FoxPro осуществляется стандартными для Windows
действиями. Перечислим возможные способы.
При использовании мыши достаточно установить курсор на пункт меню, содержащий выбираемую команду, и нажать кнопку мыши. Если команда содержит
подменю, следует выбрать в нем требуемую команду.
При использовании клавиатуры сначала нужно активизировать строку меню нажатием клавиши !}