xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

SetColor()

Retrieves and/or changes the current color setting for text mode.

Syntax

SetColor( [<cNewColorString>] ) --> cOldColorString

Arguments

<cNewColorString>
The parameter is a character string holding color settings. The first five colors are used for different pre-defined scopes. A color setting consists of a color pair that defines the foreground and background color in text mode applications. Single colors are specified with a letter (see description), foreground and background colors must be separated with a slash, and color pairs for different scopes must be comma separated.

Color settings in a color string
SettingPositionScope
Standard1All screen output commands and functions
Enhanced2GETs and selection highlights
Border3Border around screen, not supported on most monitors
Background4Not supported
Unselected5Unselected GETs

Return

The function returns a color string holding the previous color settings.

Description

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
LetterColor monitorMonochrome
BBlueUnderline
B+Bright BlueBright Underline
BGCyanWhite
BG+Bright CyanBright White
GGreenWhite
G+Bright GreenBright White
GRBrownWhite
GR+YellowBright White
IInverse VideoInverse Video
N+GrayBlack
N, SpaceBlackBlack
RRedWhite
R+Bright RedBright White
RBMagentaWhite
RB+Bright MagentaBright White
UBlackUnderline
WWhiteWhite
W+Bright WhiteBright White
XBlankBlank

Info

See also:ColorSelect(), IsDefColor(), SET COLOR, SET INTENSITY, SetBlink()
Category: Screen functions
Source:rtl\setcolor.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe