[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
+---------------------------------+
| ON SELECTION POPUP |
+---------------------------------+
ON SELECTION POPUP <popup name>
| ALL [<command>]
-----------------------------------
Assigns routine to popup.
-----------------------------------
ON SELECTION POPUP assigns a routine to a popup. When you choose any
option from the popup, the routine is executed. The routine may be a
command or a program. ON SELECTION POPUP should be placed between
DEFINE POPUP and ACTIVATE POPUP.
Routines can be assigned to individual popup options with ON SELECTION
BAR; popups and menu bars may be assigned to individual options with ON
BAR.
<popup name>
The popup you want to assign a routine to.
ALL
Assigns the routine to every active popup.
<command>
The routine to be executed when any option from the specified popup is
chosen. ON SELECTION POPUP without <command> releases routines.
+---------------------------------+
| Program Example |
+---------------------------------+
The following program example named SYSTIME.PRG places a Time & Date pad
in the System menu bar. The clock, date and day of the week can be
toggled on and off from within the Time & Date popup.
ON SELECTION POPUP is used in this example to execute the TOGGLE
routine. When any option is chosen from the TIMEPOP popup, the TOGGLE
routine is executed; BAR() passes the chosen bar number to the routine.
SET MARK and MRKBAR() place or remove a mark character to the left of
each option and determine if an option has a mark character.
*** Name the program systime.prg ***
SET TALK OFF
SET CLOCK OFF
DEFINE BAR 1 BEFORE _MST_FILER OF _MSYSTEM ;
PROMPT '\<Time & Date' KEY SHIFT+F2, 'F2 '
DEFINE POPUP timepop MARGIN && Menu popup for System menu pad
DEFINE BAR 1 OF timepop PROMPT '\<Clock '
DEFINE BAR 2 OF timepop PROMPT '\<Date '
DEFINE BAR 3 OF timepop PROMPT 'Da\<y '
DEFINE BAR 4 OF timepop PROMPT '\-' && Draw a separator
DEFINE BAR 5 OF timepop PROMPT '\<Show All '
DEFINE BAR 6 OF timepop PROMPT 'Clear \<All '
ON BAR 1 OF _MSYSTEM ACTIVATE POPUP timepop
ON SELECTION POPUP timepop DO toggle IN systime WITH BAR()
PROCEDURE toggle
PARAMETER barnumber
clockcolor = SCHEME(1,7)
DO CASE && CASE for each option
CASE barnumber = 1 && Clock option
*** Set clock on or off, toggle mark character ***
SET MARK OF BAR 1 OF timepop TO NOT MRKBAR('timepop', 1)
IF MRKBAR('timepop', 1) = .T.
SET CLOCK ON
ELSE
SET CLOCK OFF
ENDIF
CASE barnumber = 2 && Date option
*** Show or clear date, toggle mark character ***
SET MARK OF BAR 2 OF timepop TO NOT MRKBAR('timepop', 2)
IF MRKBAR('timepop', 2) = .T.
@ 1,70 SAY DATE() COLOR (clockcolor)
ELSE
@ 1,68 CLEAR TO 1,79
ENDIF
CASE barnumber = 3 && Day option
*** Show or clear day, toggle mark character ***
SET MARK OF BAR 3 OF timepop TO NOT MRKBAR('timepop', 3)
IF MRKBAR('timepop', 3) = .T.
@ 2,70 SAY CDOW(DATE()) COLOR (clockcolor)
ELSE
@ 2,70 CLEAR TO 2,79
ENDIF
CASE barnumber = 5 && Show all option
*** Set all marks to .T., turn on clock, show date and day ***
SET MARK OF BAR 1 OF timepop TO .T.
SET MARK OF BAR 2 OF timepop TO .T.
SET MARK OF BAR 3 OF timepop TO .T.
SET CLOCK ON
@ 1,70 SAY DATE() COLOR (clockcolor)
@ 2,70 SAY CDOW(DATE()) COLOR (clockcolor)
CASE barnumber = 6 && Clear all option
*** Set all marks to .F., turn off clock, clear date and day ***
SET MARK OF BAR 1 OF timepop TO .F.
SET MARK OF BAR 2 OF timepop TO .F.
SET MARK OF BAR 3 OF timepop TO .F.
SET CLOCK OFF
@ 1,70 CLEAR TO 2,79
ENDCASE
RETURN
-----------------------------------
See Also: ACTIVATE POPUP, BAR(), DEFINE BAR, DEFINE POPUP, ON BAR, ON
SELECTION BAR, POPUP()
-----------------------------------
See Also:
ACTIVATE POPUP
BAR()
DEFINE BAR
DEFINE POPUP
ON BAR
ON
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson