The following example uses the SetSysColors function to change the color of active window borders to dark purple, of active title bars to dark cyan, and of the window background to light gray.
// window elements to change
int aiElements[3] = {COLOR_ACTIVEBORDER,
COLOR_ACTIVECAPTION,
COLOR_WINDOW};
// array of RGB values
DWORD aColors[3];
// Define the new colors.
aColors[0] = RGB(0x80, 0x00, 0x80); // dark purple
aColors[1] = RGB(0x00, 0x80, 0x80); // dark cyan
aColors[2] = RGB(0xC0, 0xC0, 0xC0); // light gray
// Set the window elements in aiElements to the colors
// specified in aColors.
SetSysColors(3, aiElements, aColors);
The next example uses the GetSysColor function to retrieve the color of the window background and displays the red, green, blue (RGB) value, in hexadecimal notation, in a message box.
DWORD dwResult; // function return value
TCHAR tchBuffer[BUFFER]; // buffer for expanded string
int nSize; // size of string
// Get the color of the window background.
dwResult = GetSysColor(COLOR_WINDOW);
nSize = sprintf(tchBuffer,
"Window color: {%x, %x, %x}",
GetRValue(dwResult),
GetGValue(dwResult),
GetBValue(dwResult));
MessageBox(NULL, tchBuffer, "GetSysColor", MB_ICONINFORMATION);