Use API functions Getrvalue,getbvalue and Getgvalue. Here is an example of changing the background color of a window by analyzing the red, green and blue. (Note: Before using the following example code, set the color of the window to clblue,clnavy or any other non-system color, such as Clbtnface)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
BYTE nRed = GetRValue(Color);
BYTE nBlue = GetBValue(Color);
BYTE nGreen = GetGValue(Color);
nRed +=10;
nBlue -=10;
nGreen *= 1.05;
Color =(TColor) RGB(nRed, nGreen, nBlue);
}
Note: The Get Series function returns a 0~255 brightness value. The return type is byte because a single brightness value is one byte. When you set the brightness value to less than 0 or greater than 255, the RGB macro truncates the extra bytes (it takes only a low 8 bits).
Note: Technically, these three get functions are not actually functions, they are C-style macros. You can see their implementation in the include\win32\wingdi.h. One result of using macros is that the function is not type-safe. You can pass char * to a macro without any warning.