The information in this article applies to:
- Microsoft Visual FoxPro for Windows, version 3.0
- Microsoft FoxPro for Windows, versions 2.5x, 2.6x
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6x
SUMMARY
When you are running a program with multiple screens that has been built
with the Form Designer or Screen Builder, it is not desirable to have the
forms or screens flash when the program starts up.
In Visual FoxPro, use the .Visible property to prevent this from happening.
In FoxPro 2.x, by using the MOVE WINDOW command to move the screens after
they are defined, you can keep them from flashing on the screen when they
start up. After the screen set is started and the first screen is in place,
the other screens can then be moved to their positions within the screen
set. Below is the code needed to keep the second and third screens from
flashing when they are started with the first screen of a three-screen set.
MORE INFORMATION
Visual FoxPro
- Create a FormSet containing three forms, using their default names of
Form1, Form2, and Form3. Change the Visible property to .F. for Form2
and Form3.
- Add two buttons named btnScr2, btnScr3 to Form1.
- Add the following code to the btnScr2 Click method:
IF ThisFormSet.Form2.visible=.F.
ThisFormSet.Form2.visible=.T.
ENDIF
- Next, add another line at the bottom of the code for the btnScr2 Click
method to set the focus to a specific object on that form. For example,
if there is a TextBox called Text1 on the form, the last line of code in
the Click method should be:
ThisFormSet.Form2.Text1.SetFocus
5. Repeat steps 3 and 4 for the btnScr3 Click method, changing the
references from Form2 to Form3.
NOTE: Similar buttons using the Setfocus method could be used on Form2 and
Form3 to switch between screens.
NOTE: As an alternative, a pageframe could be used to accomplish this too.
FoxPro 2.x
- Create a screen called SCR_ONE.
- From the Screen menu, choose Layout (choose Screen Layout in FoxPro
for MS-DOS). In the Name box, type "firstscr" (without the quotation
marks). If you are using FoxPro for Windows, choose the Code button
and then choose Screen Setup Code. If you are using FoxPro for MS-DOS,
select the Setup check box. In this box, type:
MOVE WINDOW secondscr TO 0,200 && This will move the
&& screens off the
MOVE WINDOW thirdscr TO 0,200 && current desktop area.
moveflag = .T.
- Create a push button with the prompts "SCREEN2" and "SCREEN3" (without
the quotation marks). Give it the variable name "m.scr1" (without the
quotation marks). In the VALID clause of the push button, type this
code:
IF moveflag = .T.
MOVE WINDOW secondscr to 0,0 && This will move the
MOVE WINDOW thirdscr to 0,0 && screens to the upper-
moveflag = .F. && left corner.
ENDIF
DO CASE
CASE m.scr1 = 1
_CUROBJ=OBJNUM(m.scr2)
CASE m.scr1 = 2
_CUROBJ=OBJNUM(m.scr3)
ENDCASE
- Create a screen called SCR_TWO.
- From the Screen menu, choose Layout (choose Screen Layout in FoxPro
for MS-DOS). In the Name box, type "secondscr" (without the quotation
marks).
- Create a push button with the prompts "SCREEN1" and "SCREEN3" (without
the quotation marks). Give it the variable name "m.scr2" (without the
quotation marks). In the VALID clause of the push button, type this
code:
DO CASE
CASE m.scr2 = 1
_CUROBJ=OBJNUM(m.scr1)
CASE m.scr2 = 2
_CUROBJ=OBJNUM(m.scr3)
ENDCASE
- Create a screen called SCR_THRE.
- From the Screen menu, choose Layout (choose Screen Layout in FoxPro
for MS-DOS). In the Name box, type "thirdscr" (without the quotation
marks).
- Create a push button with the prompts "SCREEN1" and "SCREEN2" (without
the quotation marks). Give it the variable name "m.scr3" (without the
quotation marks). In the VALID clause of the push button, type this
code:
DO CASE
CASE m.scr3 = 1
_CUROBJ=OBJNUM(m.scr1)
CASE m.scr3 = 2
_CUROBJ=OBJNUM(m.scr2)
ENDCASE
- Bring up screen SCR_ONE. From the PROGRAM menu, choose Generate. Add
screens SCR_TWO and SCR_THRE to the screen set, and then generate the
screen set. At the Command window, type "DO scr_one.spr" (without the
quotation marks).
The screens will not flash because they have been moved. If one of the push
buttons is pressed, screen 2 and screen 3 will move to the upper-left
corner of the screen. The HIDE WINDOW command also can be used to hide the
screens that are not on top until they are called.
|