| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Retrieves and/or changes the current color setting for text mode.
SetColor( [<cNewColorString>] ) --> cOldColorString
Color settings in a color string
| Setting | Position | Scope |
|---|---|---|
| Standard | 1 | All screen output commands and functions |
| Enhanced | 2 | GETs and selection highlights |
| Border | 3 | Border around screen, not supported on most monitors |
| Background | 4 | Not supported |
| Unselected | 5 | Unselected GETs |
The function returns a color string holding the previous color settings.
SetColor() is used to query or change the current color settings for screen output in text mode applications. A single color value consists of two letters separated by a backslash. They define the foreground and background color.
A color value can be modified with a color attribute. The plus sign (+) raises the intensity, or brightness, of a color, while the asterisk can be interpreted either a as intensity or as blink attribute (see function SetBlink())
The letters listed in the following table are recognized as color values:
Letters for colors in text mode
| Letter | Color monitor | Monochrome |
|---|---|---|
| B | Blue | Underline |
| B+ | Bright Blue | Bright Underline |
| BG | Cyan | White |
| BG+ | Bright Cyan | Bright White |
| G | Green | White |
| G+ | Bright Green | Bright White |
| GR | Brown | White |
| GR+ | Yellow | Bright White |
| I | Inverse Video | Inverse Video |
| N+ | Gray | Black |
| N, Space | Black | Black |
| R | Red | White |
| R+ | Bright Red | Bright White |
| RB | Magenta | White |
| RB+ | Bright Magenta | Bright White |
| U | Black | Underline |
| W | White | White |
| W+ | Bright White | Bright White |
| X | Blank | Blank |
| See also: | ColorSelect(), IsDefColor(), SET COLOR, SET INTENSITY, SetBlink() |
| Category: | Screen functions |
| Source: | rtl\setcolor.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// This example demonstrates how to save, change and restore
// color settings.
PROCEDURE Main
LOCAL cOldColor := SetColor()
LOCAL cNewColor := PadR( "W+/N,W+/B", 40 )
CLS
? "Current color :", cOldColor
?
SetColor( cNewColor )
@ Row(), Col() SAY "Enter new color:" GET cNewColor
READ
cNewColor := Trim( cNewColor )
SetColor( cNewColor )
? "New color is :", cNewColor
SetColor( cOldColor )
? "Back to original"
RETURN
http://www.xHarbour.com