ID: Q128207
2.60a WINDOWS
The information in this article applies to:
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.
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.
1. Issue the following to create a new screen:
CREATE SCREEN MAGIC
2. Pick Layout from the Screen menu pad. Then choose the Color... button.
3. Set the background to light gray. Then click OK twice to return.
4. Add a push button in the lower center of the screen.
5. Enter the following as the push button Prompt:
\<Pres-to!
6. Name the variable hocus.
7. 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
8. Add another push button in the upper center of the screen.
9. Enter the following as the push button Prompt:
\<Abracadabra!
10. Name the variable pocus.
11. Mark it as Initially Disabled.
12. In the WHEN clause, enter this command:
WAIT WINDOW "Voila!" NOWAIT
13. Surround the Abracadabra push button with a Box object.
14. While the Box is selected, choose Object from the menu.
15. Select light gray for Fill color and also for Pen color.
16. Generate the screen. Then open the .SPR as shown:
MODIFY COMMAND MAGIC.SPR
17. 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)
18. Highlight the entire statement. Then copy it by pressing CTRL+C or by
choosing Copy from the Edit menu.
19. Close the .SPR file. Then execute the MODIFY SCREEN MAGIC command.
20. Under Screen Layout, choose Code... and select On Refresh.
21. Select the procedure box. Then paste the code by pressing CTRL+V or by
choosing Paste from the Edit menu.
22. 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.
Additional reference words: FoxWin 2.60a KBCategory: KBSubcategory: FxprgGeneral
Keywords : kbcode FxprgGeneral
Version : 2.60a
Platform : WINDOWS
Last Reviewed: May 22, 1998