Liberty BASIC Help Online |
Colors and the Graphical User Interface
By default, Liberty BASIC gives windows and controls standard colors from the user's Windows Control Panel settings. Several special variables are provided to change the colors of certain windows and controls. These variables are case sensitive, and must be typed in the proper case. For example, "backgroundcolor$" is not the same as "BackgroundColor$". The following code creates a window with a dark blue background and light gray text. It does this by setting the BackgroundColor$ and ForegroundColor$ variables BEFORE OPENING THE WINDOW:
'set the foreground and background colors
BackgroundColor$ = "darkblue"
ForegroundColor$ = "lightgray"
statictext #dialog.static, "What is your name?", 10, 10, 100, 20
textbox #dialog.tbox, 10, 30, 100, 20
button #dialog.accept, "Accept", [gotIt], UL, 10, 55
open "Name getter" for dialog as #dialog
print #dialog.tbox, "Type your names in here."
print #dialog, "trapclose [quit]"
wait
[gotIt]
print #dialog.tbox, "!contents? name$"
notice "Hi "; name$
wait
[quit]
close #dialog
end
Setting BackgroundColor$ sets the color of the background of the window, and of groupboxes, checkboxes, radiobuttons and statictext controls. Setting the ForegroundColor$ sets the color of text displayed in all controls. Only the last ForegroundColor$ and BackgroundColor$ values set before a window is opened are valid for that window. Other special color variables exist for setting the background color of several widgets:
TextboxColor$
ComboboxColor$
ListboxColor$
TexteditorColor$
The value of the TextboxColor$, TexteditorColor$, ListboxColor$ or ComboboxColor$ variable can be changed in between each control statement. A control will be colored according to the last color statement listed before the command to create the control. Below is a short example:
WindowWidth = 550
WindowHeight = 410
TextboxColor$ = "red"
textbox #main.textbox1, 26, 16, 100, 25
TextboxColor$ = "blue"
textbox #main.textbox2, 30, 61, 100, 25
TextboxColor$ = "yellow"
textbox #main.textbox3, 30, 121, 100, 25
open "untitled" for dialog as #main
[main.inputLoop] 'wait here for input event
wait
Here is a list of valid colors (in alphabetical order):
black, blue, brown, buttonface, cyan, darkblue, darkcyan, darkgray, darkgreen, darkpink, darkred, green, lightgray,
palegray, pink, red, white, yellow
"Palegray" and "Lightgray" are different names for the same color. "Buttonface" is the default background color currently set on a user's system, so it will vary according to the desktop color scheme. The colornames are not case sensitive, so "WHITE" is the same as "white." Here is a graphical representation of the available colors:
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/