2.5x 2.60 2.60a | 2.00 2.5x 2.60 2.60a | 2.5x 2.60a
WINDOWS | MS-DOS | MACINTOSH
kbprg kbusage kbcode kbappnote
The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
- Microsoft FoxPro for Macintosh, versions 2.5x, 2.6a
SUMMARY
Although the FoxPro Screen Builder allows a data input screen to be
combined with a separate Browse window, the GET fields of the data input
screen and the information in the Browse window cannot be combined in a
single window. However, the screen can be programmed so that the GET fields
and the browse information appear to be in a single window, as explained
below.
NOTE: For a more complete description of combining a Browse window with GET
fields, please refer to Application Note FW1125.
For a description of Application Note FW1125 and how to obtain it, please
see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q124606
TITLE : SAMPLE: Fw1125.exe Combines a Browse Window with Get Fields
MORE INFORMATION
This example uses GET fields from the CUSTOMER.DBF table in conjunction
with a browse of related records in the INVOICES.DBF table. It is assumed
that the CUSTOMER.DBF and INVOICES.DBF tables have been installed in the
TUTORIAL subdirectory in the main FoxPro directory.
The steps below create three windows:
- Window #1, called WBIG, is a large window with a border that acts as a
visual frame around the GET screen and the Browse window.
- Window #2, called WGETS, contains GET fields and push buttons. It does
not have a border.
- Window #3, called WBROWSE, contains the browse information of the
invoices records found in the INVOICES table.
NOTE: The actual screen coordinates of the windows matter only insofar as
WGETS and WBROWSE are contained within WBIG.
Create the Screens
To create these windows using the Screen Builder power tool, do the
following:
- In the Command window, type "CREATE SCREEN getbrow" (without the
quotation marks) to create a screen using the Screen Builder.
- From the Screen menu, choose Quick Screen. When prompted, select
CUSTOMER.DBF from the <FoxPro_directory>\TUTORIAL subdirectory, then
choose Open.
- In the Quick Screen dialog box, select the Fields check box.
- Move CNO and COMPANY to the Selected Fields list box. Choose OK twice
to return to the Screen Design window.
NOTE: Because the WGETS window will be defined as eight lines high,
these fields should be located in the first eight rows of the screen.
If fields are defined beyond this point, a "Position off screen" error
will be generated when the .SPR file is run.
- FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: From the Screen menu,
choose Layout. In the Name text box, type "WGETS" (without the
quotation marks) for the screen name. Do NOT choose OK yet.
FOXPRO FOR MS-DOS: From the Screen menu, choose Screen Layout. Select
the Window option button at the top of the dialog box. In the Name text
box, type "WGETS" (without the quotation marks) for the screen name. Do
NOT choose OK yet.
- FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Under Options, choose the
Code button.
FOXPRO FOR MS-DOS: Skip to step 7.
- FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Choose both the Screen Setup
Code and Cleanup And Procedures buttons. Choose OK twice.
FOXPRO FOR MS-DOS: Under Screen Code, choose both the Setup and
Cleanup & Procs check boxes. Choose OK once.
- Locate the "getbrow - Setup" editing window and type the following code
in it:
CLOSE DATABASES
SELECT 1
USE SYS(2004)+"\TUTORIAL\customer.dbf"
* SYS(2004) Returns the name of the directory that
* FoxPro was started from.
SELECT 2
USE SYS(2004)+"\TUTORIAL\invoices.dbf"
SET SAFETY OFF && Prevents error message if tag already exists.
INDEX ON cno TAG cno ADDITIVE
SET SAFETY ON
SELECT 1
SET RELATION TO cno INTO invoices ADDITIVE
SET SKIP TO invoices && Establishes one-to-many relationship.
DEFINE WINDOW wbig FROM 1,1 TO 22,80 DOUBLE
DEFINE WINDOW wgets FROM 0,5 TO 8,75;
IN WINDOW wbig NONE
DEFINE WINDOW wbrowse FROM 9,0 TO 20,80;
IN WINDOW wbig NONE
ACTIVATE WINDOW wbig
SELECT invoices
ACTIVATE WINDOW wbrowse
BROWSE WINDOW wbrowse IN WINDOW wbig SAVE NOWAIT
SELECT customer
ACTIVATE WINDOW wgets
- Type the following code in the "getbrow - Cleanup" editing window:
RELEASE WINDOW wbig, wbrowse
- From the Program menu, choose Generate.
- When prompted to save changes to the file, choose Yes.
- When prompted to save environment information, choose No.
NOTE: The environment is controlled by the code in "getbrow - Setup" in
Step 8.
- FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: In the Generate Screen
dialog box, choose the More button.
FOXPRO FOR MS-DOS: Skip to step 14.
- Clear the Define Windows check box, then choose Generate.
To run the program, type "DO getbrow.spr" (without the quotation marks) in
the Command window.
NOTE: No records are displayed in the Browse window of this example because
the first record in the CUSTOMER table doesn't have any related INVOICES
records. To move through the tables so that you can see other records, add
the control buttons described in the next section.
Control Buttons
To create push buttons to move forward or backward through the tables, or
to close the screen, perform the following steps:
- Type "MODIFY SCREEN getbrow" (without the quotation marks) to open the
screen.
- To place a push button object on the screen immediately below the
COMPANY GET field, do one of the following:
FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: From the toolbox, choose the
push button tool. Click the area directly below the COMPANY GET field to
place the push button object.
FOXPRO FOR MS-DOS: From the Screen menu, choose Push Button.
NOTE: The push button object must not overlap the areas used by the
WGETS or WBROWSE windows.
- Under Push Button Prompts, type "Next", "Prior", and "Quit" (without
the quotation marks) on separate lines. In the Variable text box, type
"BUTVAL" (without the quotation marks). Do NOT choose OK yet.
- FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Under Clauses, choose the
Valid button.
FOXPRO FOR MS-DOS: Under Options, select the Valid check box.
- Verify that the Procedure option button is selected, then type the
following code in the text box:
SELECT customer
SET SKIP TO && Removes one-to-many relationship so that the SKIP
* statement below doesn't move through the INVOICES
* records.
DO CASE
CASE butval = 1
IF (!EOF())
SKIP 1
ENDIF
CASE butval = 2
IF (!BOF())
SKIP - 1
ENDIF
CASE butval = 3
CLEAR READ
ENDCASE
SET SKIP TO invoices && Reestablishes one-to-many relationship.
SHOW GETS
- Choose OK twice to return to the Screen Design window.
- FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Skip to step 8.
FOXPRO FOR MS-DOS: Drag the push button to a location immediately below
the COMPANY GET field.
- Generate the code for the screen again. Be sure to clear the Define
Windows check box.
NOTE: Not all CUSTOMER records have corresponding INVOICES records. Also,
note that "Atec Data Service" is the first CUSTOMER record that has
multiple related INVOICE records.
Switching Between the Screens
Two keyboard methods can be used to switch between the Browse window and
the GET screen:
- CTRL+F1 can be used to cycle through any open windows. To use this
keyboard shortcut, the FoxPro system menu, or a menu using the system
menu bar _MWI_ROTAT with a shortcut key of CTRL+F1, must be currently
defined in memory. The menu must be accessible by setting SYSMENU to ON
or AUTOMATIC. If other windows are currently open, pressing CTRL+F1 may
cycle through these unrelated windows.
-or-
- An ON KEY LABEL command can be defined to switch between the two
windows. To define this command, do the following:
a. Type "MODIFY SCREEN getbrow" (without the quotation marks) to
open the screen.
b. From the Screen menu, choose Open All Snippets.
c. Locate the "getbrow - Setup" editing window, then add the following
as the first two lines of code:
SET SYSMENU ON && Enables CTRL+F1 to switch.
ON KEY LABEL F2 DO switchwin && Enables F2 to switch.
d. In the "getbrow - Cleanup" editing window, add the following as the
last lines of code:
ON KEY LABEL F2 && Clear the F2 key when done.
PROCEDURE switchwin
IF WONTOP('WGETS')
SELECT customer
ACTIVATE WINDOW wbrowse
BROWSE WINDOW wbrowse IN WINDOW wbig SAVE NOWAIT
ELSE
SELECT invoices
ACTIVATE WINDOW wgets
ENDIF
e. Generate the code for the screen again. Be sure to clear the Define
Windows check box.
In this example, the F2 key is used to switch between windows using the
procedure SWITCHWIN. This procedure determines which window is currently
the active output window and activates the other window. This method
does not require access to the menu bar, and will cycle only between the
GET screen and the Browse window.
|