Gray Strings Without GrayString

In versions of Windows prior to 3, the display drivers for the EGA and VGA supported only eight pure colors (black, red, green, blue, yellow, magenta, cyan, and white) on color displays. Grays had to be simulated using a dithered pattern of black and white pixels.

Beginning in Windows 3, the EGA and VGA display drivers support 16 colors, including two shades of gray. This means that you can display gray text without using the GrayString function.

To do this, first call GetSysColor with a parameter of COLOR_GRAYTEXT:

rgbGrayText = GetSysColor (COLOR_GRAYTEXT) ;

If rgbGrayText is equal to 0L, then your program should use the GrayString function to draw a grayed string. Otherwise, you can simply set the text color to rgbGrayText:

SetTextColor (hdc, rgbGrayText) ;