The information in this article applies to:
- Microsoft FoxPro for Windows, version 2.6a
SUMMARY
This article shows by example how to offer a GET object for selection only
after specific criteria are met, preventing the selection and display of
the GET object at all other times.
Although a simple WHEN test controls selection of a GET object, it does not
prevent the user from viewing it if the condition is not met. In the case
of input fields, the disabled colors can be set to the same colors as the
background screen, causing it to effectively disappear. Unfortunately, this
technique won't work for buttons and popups, and disabling the GET does not
prevent the button or popup object from appearing on the screen in dithered
colors.
MORE INFORMATION
Step-by-Step Example
The following code demonstrates how to define objects in Screen Builder
that through sleight-of-Hand give the appearance of disappearing and
re-appearing on command. The example demonstrates how to hide the GET
object when the screen is initially displayed, and then reveal it in
response to a push button.
- Issue the following to create a new screen:
CREATE SCREEN MAGIC
- Pick Layout from the Screen menu pad. Then choose the Color... button.
- Set the background to light gray. Then click OK twice to return.
- Add a push button in the lower center of the screen.
- Enter the following as the push button Prompt:
\<Pres-to!
- Name the variable hocus.
- In the VALID clause, add the following code:
IF hocus = 'Pres-to!!'
SHOW GET hocus,1 PROMPT 'Change-o!'
SHOW GET pocus,1 ENABLED
ELSE
SHOW GET hocus,1 PROMPT 'Prest-o!!'
SHOW GET pocus,1 DISABLED
SHOW GETS OFF
ENDIF
- Add another push button in the upper center of the screen.
- Enter the following as the push button Prompt:
\<Abracadabra!
- Name the variable pocus.
- Mark it as Initially Disabled.
- In the WHEN clause, enter this command:
WAIT WINDOW "Voila!" NOWAIT
- Surround the Abracadabra push button with a Box object.
- While the Box is selected, choose Object from the menu.
- Select light gray for Fill color and also for Pen color.
- Generate the screen. Then open the .SPR as shown:
MODIFY COMMAND MAGIC.SPR
- Locate the line in the Screen Layout section of the .SPR file that
creates the Box object, such as the following example:
@ 7.385,19.200 TO 14.847,38.600 ;
PATTERN 1 ;
PEN 1, 8 ;
COLOR RGB(192,192,192,192,192,192)
- Highlight the entire statement. Then copy it by pressing CTRL+C or by
choosing Copy from the Edit menu.
- Close the .SPR file. Then execute the MODIFY SCREEN MAGIC command.
- Under Screen Layout, choose Code... and select On Refresh.
- Select the procedure box. Then paste the code by pressing CTRL+V or by
choosing Paste from the Edit menu.
- Regenerate the screen. Close the .SCX file and execute the DO MAGIC.SPR
command.
To test the effect, click the 'Prest-o!!' button to cause the hidden button
to appear. Click the 'Abracadabra!' button. Then click the 'Change-o!'
button to cause the button to vanish. Then click where the other button was
to show it is no longer accessible.
|