In this little and easy code snippet I will explain the most important things about using RGB colour values in your Windows applications. If you know how to use them, you will be able to use many of the Windows graphics functions.
The datatype that is used to represent colour values under Windows is called COLORRED and is defined like this:
COLORREF isn't a structure itself but a typedef - a second name - for a DWORD which is itself an unsigned long. This type alone doesn't help us much when using colour values so we need another helper the macro RGB with whom we can construct any colour value with the basic colours red, green and blue.
Every colour value has to be between 0 and 255 where 0 means no intensity and 255 means full intensity. So RGB(0,0,0) is black and RGB(255,255,255) is white. In total this gives us the possibility to use over 16 million colour values.
Creating new colours with RGB is really easy and can be compared with mixing colours on a palette. Beside creating new colours, there are three macros that extract the corresonding red, green or blue value from an exisiting COLORREF value.
To complete the code snippet, here's an example from real life:
You should now know everything about colour values. If you still have questions, ask them in the message board. Happy Coding by the way!