SetTextColor function

The SetTextColor function sets the text color for the specified device context to the specified color.

Syntax

COLORREF SetTextColor(
  HDC      hdc,
  COLORREF color
);

Parameters

hdc

A handle to the device context.

color

The color of the text.

Return Value

If the function succeeds, the return value is a color reference for the previous text color as a COLORREF value.

If the function fails, the return value is CLR_INVALID.

Remarks

The text color is used to draw the face of each character written by the TextOut and ExtTextOut functions. The text color is also used in converting bitmaps from color to monochrome and vice versa.

Examples

For an example, see "Setting Fonts for Menu-Item Text Strings" in Using Menus.

Requirements

   
Windows version Windows 2000 Professional [desktop apps only] Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See Also

BitBlt

COLORREF

ExtTextOut

Font and Text Functions

Fonts and Text Overview

GetTextColor

RGB

SetBkColor

StretchBlt

TextOut