[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
twButtonBox( bType, Msg, Title, NoButtons, Buttons,;
sButton, wT, wL, wB, wR, wSType, wFType,;
ExitKey, ActionKeys )
----------------------------------------------------------------------------
Display a window containing message text and an array of choices
which are presented as 'Push Buttons' in the manner of an
ACHOICE() or MENU TO. The choice array can be displayed
horizontally or vertically. The function can be made to optionally
execute code passed as code blocks and can use a default or a user
defined exit key. The window is displayed with the shadow and
frame type of the currently active window, as are the 'Push
Buttons', which are displayed with thin shadows.
Code to be executed, as defined in ActionKeys DOES NOT constitute
an EXIT key. Therefore, twButtonBox() can easily be used as a menu
shell in your applications. (See the BUMENU Demo for Details )
The choice array, Buttons[], has default values, as do the display
coordinates. If either the message or the choice array will write
outside the display window, it is truncated. The programmer must
ensure the allocated area is big enough to hold all the
information required.
twButtonBox() Configuration
Horizontal Vertical
+--------- Title --------+ +--------- Title --------+
| | | |
| | | Message Text Choice1 |
| Message Text | | |
| | | goes in Choice2 |
| goes in | | |
| | | this area Choice3 |
| this area | | |
| | | Choice4 |
| | | |
| | | etc. |
| Choice1 Choice2 etc. | | |
+------------------------+ +------------------------+
The Up, Down, Right and Left cursor keys move the highlight one
choice, as in a MENU TO. The Page Up and Home keys highlight the
first choice. The Page Down and End keys highlight the last
choice. Any choice NOT associated with an ActionKey will cause an
exit. The default exit key for twButtonBox() is the ENTER key,
which causes the function to return 0.
Arguments:
bType - 'C' "V" or "v" for vertical choice display. "H" or
"h" for horizontal.
Msg - 'C' Character string to be displayed as a message.
The message is displayed in part of the window
left AFTER the choice array is processed.
In the vertical configuration, the choices appear
on the right and the message in the area of the
window remaining on the left. In the horizontal
configuration, the choices appear at the bottom
of the window and the message is displayed in the
top area.
Title - 'C' Optional title for the twButtonBox() window.
NoButtons - 'N' If using the defaults, you may pass 1, 2 or 3 to
indicate the number of buttons to display. If you
pass this parameter, it is not necessary to pass
a choices array. If you pass a choices array,
NoButtons is ignored.
Buttons - 'A' This array holds the choices to be displayed as
an array of strings. The function formats the
buttons to the length of the longest element in
this array. If Buttons is NOT passed, the
defaults are:
NoButtons = 1
Buttons := { "OK" }
NoButtons = 2
Buttons := { "Yes", "No" }
NoButtons = 3
Buttons := { "Yes", "No", "Cancel" }
sButton - 'N' The number of the default button to start with.
wT, wL - 'N' Screen coordinates for the display
wB, wR area.
wSType - 'N' TSDWIN shadow type. Defaults to the shadow type
for the currently active window.
wFType - 'N' TSDWIN frame type. Defaults to the frame type for
the currently active window.
ExitKey - 'A' The default exit key array is
{ K_ENTER }
If you want to allow more, say, pass an array
like:
{ K_ESC, K_F4 }
ActionKeys - 'A' This optional parameter allows you to require
twButtonBox() to execute code WITHOUT exiting.
Each element in the array must have two elements,
the first to indicate which choice button you
wish to invoke, the second, a code block to
execute when that button is invoked.
Return:
The Choice number or zero if an Exitkey was chosen.
Example:
ActionKeys := { { 1, { || Proc01() } }, ;
{ 2, { || Proc02() } }, ;
{ 3, { || Proc03() } }, ;
{ 4, { || Proc04() } }, ;
{ 5, { || Proc05() } }, ;
{ 6, { || Proc06() } } }
twButtonBox( "V", ;
"Welcome to the twButtonBox Menu Demonstration. "+ ;
"This program was created using the TSDWIN.LIB "+ ;
"twButtonBox MaxiFunction. You get more golfing in "+ ;
"with TSDWIN.LIB looking after the details!", ;
"BuMenu Main Menu",, ;
{ "Choice Number 1", ;
"Choice Number 2", ;
"Choice Number 3", ;
"Choice Number 4", ;
"Choice Number 5", ;
"Choice Number 6", ;
"Return to DOS" },, ;
4, 15, 20, 65, 3, 8,, ActionKeys )
Compile, Link and Run BUMENU.PRG to see this code fragment
execute.
This code segment actually operates like a menu. Normally one
would use twButtonBox() to present the user with choices in a
configuration or error situation, such as offering the choice to
continue or not when the printer is found to be offline.
See Also:
twAlertInit()
twCheckBox()
twRadioBox()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson