provided by: 
Originally published at Internet.comThis article was contributed by Christian Rodemeyer. [Method overview] The class CColor encapsulates the GDI color value (COLORREF) and adds some comfortable functions: direct manipulation of RGB and HSL attributes, conversion to string values for storage (registry, databases) and user-friendly color names. By userdefined constructors and conversions is it possible to use a CColor object everywhere a COLOREF value is expected. The attributes red, green and blue can be separatly accessed. This is an improvement compared with the use of makros like RGB, GetRValue, GetBValue and GetGValue. Likewise the attributes of the HLS color model (hue, luminance and saturation) can be separatly read and manipulated. In this manner it is very easy to draw color gradients like the title bars of Windows98 application or a "Choose Color" dialog. The MSDN Library provides an article which describes the HLS color model under the title "HLS Color Spaces". Colors could principially be stored in the registry or in databases numerically as DWORDs, but their manipulation through regedit like tools or SQL is unneccessarily complicated in this form. But it is more clever to store colors as text in the hexadecimal format RRGGBB. This text could be, in the worst case, manipulated by hand from some experienced user or system administrator. To get and set the text representation of a color you can use the handy GetString and SetString methods. Under X11 you can use named colors since long. HTML (respectively Internet Explorer) supports them too. Constants and strings are defined for every named color supported by Internet Explorer. Using named colors makes code more readable, because the constant "chocolate" is more understandable than the expression "RGB(0xD2691E)". The name of a color could also be determined as a string data type. It can be used as a means of communication between program and user. Remark: The CColor class does not support palettes and has therefore the greatest use, if windows is be used with more than 256 colors (color depth greater or equal 15/16bit)
Method Overview
CColor Consturctor for COLORREF compatibility. operator COLORREF Conversion operator for COLORREF compatibility. RGB SetRed Sets the red portion of the color (0 - 255). SetGreen Sets the green portion of the color (0 - 255). SetBlue Sets the blue portion of the color (0 - 255). SetRGB Sets the red, green and blue portion of the color in one step. GetRed Gets the red portion of the color (0 - 255). GetGreen Gets the green portion of the color (0 - 255). GetBlue Gets the blue portion of the color (0 - 255). HSL SetHue Sets the hue (0.0 - 360.0, angle in color circle). SetLuminance Sets the luminance (0.0 - 1.0). SetSaturation Set the saturation (0.0 - 1.0). SetHLS Sets the hue, luminance and saturation in one step. GetHue Gets the hue (0.0 - 360.0, angle in color circle). GetLuminance Gets the luminance (0.0 - 1.0). GetSaturation Liefert die Farbsättigung (Wertebereich: 0.0 - 1.0). String SetString Sets the color through extracting it from a string in the hexadecimal format RRGGBB GetString Gets a string which describes the color as a value in the hexadecimal format RRGGBB. Named Colors GetName Gets the user friendly name of the color Farbe. Static GetNameFromIndex Gets the name belonging to a value of ENamedColorIndex . GetColorFromIndex Gets a CColor object, which is initialized with the color represented by a value of ENamedColorIndex GetNumNames Gets the number of named colors. -----------------------------------
Konstanten
CColor::ENamedColor
...
Read article at Internet.com site