From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC


The graphicbox is a control that can be added to any window type, except TEXT. It understands all of the commands that are used in a window of type GRAPHICS.
For a list of Graphics Commands, see Graphics


  1. GRAPHICBOX #handle.ext, x, y, wide, high

Graphicbox Features

  • Use of Graphicbox. Graphicboxes, like graphic windows, are mainly used for drawing and displaying graphics - pictures, shapes, lines, colors, etc.
  • Persisting graphics. By default, anything you draw on graphic box is not persisting. That is, it will not get redrawn automatically after window being obscured (or minimised). You should understand the conscept, flush command is a good start (and might as well be all you need to know about this).
  • Other controls in Graphicboxes. Some controls will not work properly when placed in graphicboxes. Therefore, it is not advisable to place controls in graphicboxes (or graphic windows).
  • Displaying Text. Graphicboxes have the unique capacity to display text in color and mixed attributes. (Other JB controls cannot do this.) The reason for this is because each character is drawn in a graphicbox as an individual graphic element. But, you do not want to use text controls for text display in graphicboxes, for the reason noted above. So, there are graphics commands just for placing text in graphicboxes.
#handle "\text"
#handle "|text"
#handle "\text1\text2\text3" 'a carriage return is inserted at each "\".
Note that the second form uses the pipe (|) character. When using this character, you can include the backslash (\) in your text, as in a file path for instance.
  • Mouse and Keyboard events. Another unique feature of graphicboxes is their ability to capture mouse movements and key presses. This enables a programmer to make a drawing program, or to allow the user to move a graphic element as in game play. These are powerful features. A graphicbox which is disabled cannot capture keyboard and mouse events. The graphicbox must have the input focus to capture events. Use the setfocus command to shift input focus from another control on the window to the graphicbox control, if necessary.
  • Graphicbox in Dialog window. It looks like Keyboard events does not work in dialog window. :(

Graphicbox Commands

The following commands are general in nature for use with graphicbox controls. See the individual pages for discussion.

Graphics Commands

For a complete listing of graphics commands for use in a graphicbox (or graphic window), see Graphics.


Then inserted into ordinary window, graphicbox breaks TAB cycling (if you press TAB to move from one control to another, moving will stop you hit graphicbox). If you need it working, you could disable graphicbox. It will fall off TAB order but will be available to draw.


An example to create a simple graphicbox in a window.

'This example uses some graphics commands that are not listed on this page.
'See Graphics Commands for discussion.

graphicbox 1, 1, 400, 300
'set window background color

    open "Graphicbox Demo" for window as #1
    #1 "trapclose [quit]"
    'make the graphicbox able to be resized with the window "autoresize"
    'set a font, size and color "font consolas 16 bold; color red"
    'put pen down over 20 pxs and down 20 pxs.
    'make background color of graphicbox yellow
    'make color behind text yellow "down; place 20 20; fill yellow; backcolor yellow"
    'print some text on two lines "\This is a\GRAPHICBOX"
    '"set" the graphic elements so window can be resized without losing the text "flush"


    close #1

Useful Procedures

' Place a useful function or sub using this keyword here