Microsoft KB Archive/97640

{|
 * width="100%"|

-

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:

"Q124606 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 &quot;CREATE SCREEN getbrow&quot; (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 \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 &quot;Position off screen&quot; 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 &quot;WGETS&quot; (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 &quot;WGETS&quot; (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 &quot;getbrow - Setup&quot; editing window and type the following code in it:  <pre class="CODESAMP">      CLOSE DATABASES SELECT 1 USE SYS(2004)+&quot;\TUTORIAL\customer.dbf&quot; * SYS(2004) Returns the name of the directory that * FoxPro was started from. SELECT 2 USE SYS(2004)+&quot;\TUTORIAL\invoices.dbf&quot;

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 </li>  Type the following code in the &quot;getbrow - Cleanup&quot; editing window:  <pre class="CODESAMP">      RELEASE WINDOW wbig, wbrowse </li> From the Program menu, choose Generate.</li> When prompted to save changes to the file, choose Yes.</li> When prompted to save environment information, choose No.

NOTE: The environment is controlled by the code in &quot;getbrow - Setup&quot; in Step 8.</li> FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: In the Generate Screen dialog box, choose the More button.

FOXPRO FOR MS-DOS: Skip to step 14.</li> Clear the Define Windows check box, then choose Generate.</li></ol>

To run the program, type &quot;DO getbrow.spr&quot; (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:

<ol> Type &quot;MODIFY SCREEN getbrow&quot; (without the quotation marks) to open the screen.</li> 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.</li> Under Push Button Prompts, type &quot;Next&quot;, &quot;Prior&quot;, and &quot;Quit&quot; (without the quotation marks) on separate lines. In the Variable text box, type &quot;BUTVAL&quot; (without the quotation marks). Do NOT choose OK yet.</li> FOXPRO FOR WINDOWS & FOXPRO FOR MACINTOSH: Under Clauses, choose the Valid button.

FOXPRO FOR MS-DOS: Under Options, select the Valid check box.</li>  Verify that the Procedure option button is selected, then type the following code in the text box:  <pre class="CODESAMP">     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 </li> Choose OK twice to return to the Screen Design window.</li> 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.</li> Generate the code for the screen again. Be sure to clear the Define Windows check box.</li></ol>

NOTE: Not all CUSTOMER records have corresponding INVOICES records. Also, note that &quot;Atec Data Service&quot; 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:

<ol style="list-style-type: lower-alpha;"> Type &quot;MODIFY SCREEN getbrow&quot; (without the quotation marks) to open the screen.</li> <li>From the Screen menu, choose Open All Snippets.</li> <li> Locate the &quot;getbrow - Setup&quot; editing window, then add the following as the first two lines of code:  <pre class="CODESAMP">        SET SYSMENU ON               && Enables CTRL+F1 to switch. ON KEY LABEL F2 DO switchwin && Enables F2 to switch. </li> <li> In the &quot;getbrow - Cleanup&quot; editing window, add the following as the last lines of code:  <pre class="CODESAMP">        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 </li> <li>Generate the code for the screen again. Be sure to clear the Define Windows check box.</li></ol>

Additional query words: FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.50c one read genscrn.prg

Keywords         : kbcode FxtoolSbuilder Version          : 2.5x 2.60 2.60a | 2.00 2.5x 2.60 Platform         : MACINTOSH MS-DOS WINDOWS Issue type       :
 * }