COLORDIALOG

COLORDIALOG color$, chosen$

Description:

This command displays the Windows Common Color Dialog to allow a user to select a color. It returns the red, green, and blue components of the color chosen, plus the Liberty BASIC name, if it happens to correlate to one of the 16 named LB colors.

Usage:

color$

This is a string containing the starting color for the dialog. It can be an empty string, but it must be included. It may be in one of two forms. It can be a named Liberty BASIC color, or a string containing the red, green, blue values of the desired color with which to seed the colordialog.

chosen$

When the dialog is closed, this variable contains the color chosen by the user.

Examples:

  colordialog "red", chosen$
  print "Color chosen is ";chosen$

or

  colordialog "255 0 0", chosen$
  print "Color chosen is ";chosen$

Red, green and blue values must each be in the range of 0 to 255. 0 is the absence of a color, and 255 is total saturation.

After the dialog closes, the receiver variable contains the red, green, blue values for the color chosen by the user. If these values correlate to a named Liberty BASIC color, that color name will be appended to the returned string.

Returned string: RGB and name for a named color

255 255 0 yellow

Returned string: RGB only for a non-named color:

250 230 190

Full Opening of Dialog

The colordialog opens a small dialog with a grid of typical colors displayed. The user can choose to click the "Define Custom Colors" button to open a full RGB color spectrum from which to choose. The full dialog looks like this: