How to Find Problems

To make sure your code is using the system colors correctly, the first step is to scan through your source files and look for suspicious code. Any color that is white, light gray, gray, dark gray, or black should be considered suspicious. While there are many functions that can result in color problems (such as the CreatePen, CreateSolidBrush, SelectObject, SetTextColor, and SetBkColor functions), I find it easier just to search for the RGB macro and the SelectStockObject function, since these are the primary ways of setting a nonsystem color. Searching for the SelectStockObject function is especially important, since this function is often used to incorrectly set pens and brushes, especially windows background brushes. When you find suspicious-looking code that is actually correct, I recommend labeling it with a comment for future reference, for example:

// Note: Nonsystem color CPen grayPen(PS_SOLID,1,RGB(192,192,192));

The comment helps ensure that the code won't be accidentally "corrected" in the future.

However, the best way to find system color problems is to set your development computer's appearance scheme to one that doesn't use any of the default GDI colors, with the possible exception of black text. This includes just about all of the predefined Windows appearance schemes except for the Windows Standard scheme or any of the VGA schemes. My personal favorite is the Plum appearance scheme. Using such an appearance scheme immediately reveals any misuse of color.

TIP
To help you find system color problems easily, always set your computer's Windows appearance scheme to one that doesn't use any of the default GDI colors.

The last test you should employ is changing the system colors while your program is running. On the Appearance tab of the Display Control Panel applet, change the colors while displaying various windows and dialog boxes. Again, the color changes should happen immediately and completely. If the changes aren't immediate, you need to handle the WM_SYSCOLORCHANGE message. If the changes aren't complete, most likely you need to re-create GDI resources using the new colors or forward the WM_SYSCOLORCHANGE message to child controls.



Developing User Interfaces for Microsoft Windows
Developing User Interfaces for Microsoft Windows
ISBN: 0735605866
EAN: 2147483647
Year: 2005
Pages: 334

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net