CONTROLS AND COLORS

I deliberately put a little ”gotcha“ into BTNLOOK. There is something wrong with the program. It may not be immediately apparent, but here's how to see it: Run BTNLOOK and bring up the Control Panel program included with Windows. Select the Colors icon; this brings up a dialog box that lets you change system colors. Select Color Palette and change the colors of Window Background and Window Text, and save the new settings by clicking the OK button: The background and text of the buttons (with the exception of the push buttons) in BTNLOOK changes to reflect the new colors, but the background color and text color of the rest of BTNLOOK's client area remain the same—black text on a white background. It looks dreadful.

What happened? Simple—the button colors change because they are based on the system colors you set in Control Panel, but BTNLOOK's client-area background remains white because white is specified in the window class:

wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;

When BTNLOOK writes text to the display, it uses the text color and background color defined in the default device context. These are always black and white, regardless of the system colors set with Control Panel.

Let's fix this problem. I discussed Windows' use of color in Chapter 5, but this problem involves Windows ”system colors.“