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:

"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: