Click here to Skip to main content
12,556,876 members (47,793 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked

Naming common colors

, 28 Jul 2001
Rate this:
Please Sign up or sign in to vote.
An include file that allows you to specify colors by name instead of RGB value
<!-- Download Links --> <!-- Article image -->

Sample Image - ColorNames.gif


I always have serious problems when it comes to the point of color selection. I guess you'll agree that basic 16 colors that windows define are boring. However, using RGB macro and guessing R,G and B values out of 256^3 possibilities is problematic (too many options). Even if I use the macro, I can hardly recognize which color is hiding behind say CBrush brush(RGB(210,105,30)).


HTML gurus experienced the same problem. To solve it they identified 141 colors and assign them appropriate names. I took their definition and convert it into a header file. If you include the header #include "ColorNames.h" into your code, you will be able to use HTML color names instead of the RGB macro, say CBrush brush(colChocolate).

I find this easier to use and to remember. I hope it will help you, too.

Below is a part of the "ColorNames.h" file and this file is all you need. The demo application will present you all 141 colors and their names.

const COLORREF colAliceBlue            = RGB(240,248,255);
const COLORREF colAntiqueWhite         = RGB(250,235,215);
const COLORREF colAqua                 = RGB(  0,255,255);
const COLORREF colAquamarine           = RGB(127,255,212); 
const COLORREF colAzure                = RGB(240,255,255);
const COLORREF colBeige                = RGB(245,245,220);
const COLORREF colBisque               = RGB(255,228,196);
const COLORREF colBlack                = RGB(  0,  0,  0);
const COLORREF colBlanchedAlmond       = RGB(255,255,205);
const COLORREF colBlue                 = RGB(  0,  0,255);
const COLORREF colBlueViolet           = RGB(138, 43,226);
const COLORREF colBrown                = RGB(165, 42, 42);
const COLORREF colBurlywood            = RGB(222,184,135);
const COLORREF colCadetBlue            = RGB( 95,158,160);
const COLORREF colChartreuse           = RGB(127,255,  0);
const COLORREF colChocolate            = RGB(210,105, 30);
const COLORREF colCoral                = RGB(255,127, 80);
const COLORREF colCornflowerBlue       = RGB(100,149,237);
const COLORREF colCornsilk             = RGB(255,248,220);
const COLORREF colCrimson              = RGB(220, 20, 60);
const COLORREF colCyan                 = RGB(  0,255,255);


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ales Krajnc
Web Developer
Slovenia Slovenia
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralNice project, but here is a change... Pin
Jan S. Yoder17-Oct-01 13:32
memberJan S. Yoder17-Oct-01 13:32 
GeneralRe: Nice project, but here is a change... Pin
Ales Krajnc17-Oct-01 21:01
memberAles Krajnc17-Oct-01 21:01 
GeneralSee CColor Pin
My name was registered1-Aug-01 2:43
memberMy name was registered1-Aug-01 2:43 
Generalcopyright disclaimer Pin
Anonymous30-Jul-01 13:16
memberAnonymous30-Jul-01 13:16 
General[Message Deleted] Pin
Ricky30-Jul-01 5:59
memberRicky30-Jul-01 5:59 
GeneralRe: Color-picker programs Pin
Alexander Berthold1-Aug-01 4:09
memberAlexander Berthold1-Aug-01 4:09 
GeneralWeb-safe colors Pin
Anonymous30-Jul-01 1:41
memberAnonymous30-Jul-01 1:41 
QuestionWhat a good idea! Pin
Anonymous Pete29-Jul-01 15:30
memberAnonymous Pete29-Jul-01 15:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161026.1 | Last Updated 29 Jul 2001
Article Copyright 2001 by Ales Krajnc
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid