COLORREF SetTextColor(hdc, clrref) | |||||
HDC hdc; | /* handle of device context | */ | |||
COLORREF clrref; | /* new color for text | */ |
The SetTextColor function sets the text color to the specified color. The system uses the text color when writing text to a device context and also when converting bitmaps between color and monochrome device contexts.
hdc
Identifies the device context.
clrref
Specifies the color of the text.
The return value is the RGB (red-green-blue) value for the previous text color, if the function is successful.
If the device cannot represent the specified color, the system sets the text color to the nearest physical color.
The background color for a character is specified by the SetBkColor and SetBkMode functions.
The following example sets the text color to red if the GetTextColor function determines that the current text color is black. The text color is specified by using the RGB macro.
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 */