CTerminalEmulator::GetColorMap Method  
 
BOOL GetColorMap(
  COLORREF *lpColor,  
  INT nMaxColors  
);

The GetColorMap method returns the virtual display color table which determines what RGB values are used to display foreground and background text color attributes.

Parameters

lpColor
A pointer to an array of COLORREF values which will contain the color values currently being used in the virtual display.
nMaxColors
The maximum number of colors which may be stored in the color array. The minimum value for this parameter is 1, and the maximum value is 16.

Return Value

If the method succeeds, the return value is a non-zero value. If the method fails, the return value is zero. Failure indicates that the handle to the virtual display is invalid, the pointer to the color table is NULL or the maximum number of color values is invalid.

Remarks

When the emulator processes an escape sequence that changes the current foreground or background color, the actual RGB color value is determined by looking up the value in the virtual display's color table. The GetColorMap method is useful for determining what values are being used when a color attribute is set. The emulator currently supports a maximum of sixteen (16) color values, and the index into the table corresponds to the color as defined by the standard for ANSI terminals:

Index Color Default (Hex) Default (Integer) Default (RGB)
Black RGB(0,0,0)
Red 000000A0h RGB(160,0,0)
Green 0000A000h RGB(0,160,0)
Yellow 0000A0A0h RGB(160,160,0)
Blue 00A00000h RGB(0,0,160)
Magenta 00A000A0h RGB(160,0,160)
Cyan 00A0A000h RGB(0,160,160)
White 00E0E0E0h RGB(224,224,224)
Gray 00C0C0C0h RGB(192,192,192)
Light Red 008080FFh RGB(255,128,128)
Light Green 0090EE90h RGB(144,238,144)
Light Yellow 00C0FFFFh RGB(255,255,192)
Light Blue 00E6D8ADh RGB(173,216,230)
Light Magenta 00FFC0FFh RGB(255,192,255)
Light Cyan 00FFFFE0h RGB(224,255,255)
High White 00FFFFFFh RGB(255,255,255)

A standard ANSI color terminal supports eight standard colors (0-7). To select a foreground color, you add 30 to the color index and pass that value as a parameter to the SGR (select graphic rendition) escape sequence. To select a background color, you add 40 to the color index. For example, to set the current foreground color to white and the background color to blue, you could send the following escape sequence:

ESC [ 37;44 m

Note that if you wanted to set the foreground color to a bold version of standard yellow, you would first set the bold attribute, and then use the index value of 3, such as:

ESC [ 1;33m

GetColorMap is typically used in conjunction with the SetColorMap method to load the current color values and then make selective changes to the actual RGB color value that is used when a color attribute is set. Note that changes to the color map will only affect new characters as they are displayed, not any previously displayed characters.

Example

The following example will load the current color table for the virtual display and change the standard white color attribute to use the same value as the high-intensity white:

COLORREF rgbColor[16];

if (pDisplay->GetColorMap(rgbColor, 16) )
{
     rgbColor[7] = rgbColor[15];
     pDisplay->SetColorMap(rgbColor, 16);
}

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csnvtv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also