GetTextColor

2.x

  COLORREF GetTextColor(hdc)    
  HDC hdc; /* handle of device context */

The GetTextColor function retrieves the current text color. The text color is the foreground color of characters drawn by using the graphics device interface (GDI) text-output functions.

Parameters

hdc

Identifies the device context.

Return Value

The return value specifies the current text color as a red, green, blue (RGB) color value, if the function is successful.

Example

The following example sets the text color to red if the GetTextColor function determines that the current text color is black:

DWORD dwColor;

dwColor = GetTextColor(hdc);
if (dwColor == RGB(0, 0, 0))    /* if current color is black */
    SetTextColor(hdc, RGB(255, 0, 0)); /* sets color to red  */

See Also

GetBkColor, GetBkMode, SetBkMode, SetTextColor