Liberty BASIC Help Online

CHECKBOX
Image checkbox.GIF
 
CHECKBOX #handle.ext, "label", setHandler, resetHandler, x, y, wide, high
 
Description:
This command adds a checkbox control to the window referenced by #handle.ext.  Checkboxes have two states, set and reset.  They are useful for getting input of on/off  type information.
 
Here is a description of the parameters of the CHECKBOX statement:
 
#handle.ext
This parameter specifies the handle for this control.  The #handle part should be the same as the handle of the window containing the checkbox, and the .ext part names the checkbox uniquely in the window.
 
"label"
This parameter contains the visible text of the checkbox
 
setHandler
This is the branch label or subroutine to go to when the user sets the checkbox by clicking on it. When the checkbox is "set" it displays a checkmark.   See also: Controls and Events
 
resetHandler
This is the branch label or subroutine to goto when the user resets the checkbox by clicking on it. When the checkbox is "reset", the checkmark is removed. See also: Controls and Events
 
x
This is the x position of the checkbox relative to the upper left corner of the window it belongs to.
 
y
This is the y position of the checkbox relative to the upper left corner of the window it belongs to.
 
wide
This is the width of the checkbox control.
 
high
This is the height of the checkbox control.
 
Checkbox Commands
Checkboxes  understand these commands:
 
print #handle.ext, "set"
This sets the checkbox, causing a checkmark to appear within it.
 
print #handle.ext, "reset"
This resets the checkbox, clearing it.
 
print #handle.ext, "value? result$"
The result$ variable is set to the status of the checkbox (either "set" or "reset").
 
print #handle.ext, "setfocus"
This causes the checkbox to receive the input focus.  This means that any keypresses are directed to the checkbox.
 
print #handle,ext, "locate x y width height"
This repositions the checkbox in its window.  This is effective when the checkbox is placed inside window of type "window".  The checkbox will not update its size and location until a REFRESH command is sent to the window.  See the RESIZE.BAS example program.
 
print #handle, "font facename pointSize"
This sets the font to the specified face and point size.  If an exact match cannot be found, then Liberty BASIC will try to find a close match, with size taking precedence over face.   For more on specifying fonts read How to Specify Fonts
 
Example:
 
print #handle.ext, "font times_new_roman 10"
 
 
print #handle.ext, "enable"
This causes the control to be enabled.
 
 
print #handle.ext, "disable"
This causes the control to be inactive and grayed-out.
 
 
print #handle.ext, "show"
This causes the control to be visible.
 
 
print #handle.ext, "hide"
This causes the control to be hidden or invisible.
 
 
 
For information on creating controls with different background colors, see Colors and the Graphical User Interface.
 
Usage
Here are sample programs that use checkboxes.
 
    ' This code demonstrates how to use checkboxes in
    ' Liberty BASIC programs with branch label handlers
    nomainwin
    button #1, "&Ok", [quit], UL, 120, 90, 40, 25
    checkbox #1.cb, "I am a checkbox", [set], [reset], 10, 10, 130, 20
    button #1, "Set", [set], UL, 10, 50
    button #1, "Reset", [reset], UL, 50, 50
    textbox #1.text, 10, 90, 100, 24
 
    WindowWidth = 180
    WindowHeight = 160
 
    open "Checkbox test" for dialog as #1
    print #1, "trapclose [quit]"
 
[inputLoop]
    input r$
 
[set]
    print #1.cb, "set"
    goto [readCb]
 
 
[reset]
  print #1.cb, "reset"
  goto [readCb]
  end
 
[readCb]
    print #1.cb, "value?"
    input #1.cb, t$
    print #1.text, "I am "; t$
    goto [inputLoop]
 
[quit] close #1 : end
 
    ' This code demonstrates how to use checkboxes in
    ' Liberty BASIC programs with subroutine handlers
 
    nomainwin
    button #1, "&Ok", [quit], UL, 120, 90, 40, 25
    checkbox #1.cb, "I am a checkbox", checkSet, checkReSet, 10, 10, 130, 20
    textbox #1.text, 10, 90, 100, 24
 
    WindowWidth = 180
    WindowHeight = 160
    open "Checkbox test" for dialog as #1
    print #1, "trapclose [quit]"
 
[inputLoop]
    input r$
 
sub checkSet cbHandle$
    print #cbHandle$, "value? v$"
    print #1.text, "I am ";v$
    end Sub
 
sub checkReSet cbHandle$
    print #cbHandle$, "value? v$"
 
    print #1.text, "I am ";v$
    end Sub
 
 
[quit] close #1 : end


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/