I'm making a program and I need to paint a rectangle of the same color as the title bar.
If I try to get the color like this:
ARGB rgbActiveColor = GetSysColor(COLOR_ACTIVECAPTION);
ARGB rgbInactiveColor = GetSysColor(COLOR_INACTIVECAPTION);
rgbActiveColor |= 0xFF000000; // Because of alpha
rgbInactiveColor |= 0xFF000000;
I get a totally different color in Windows 8. It always returns a orange or brown color instead of the actual color (let's say, blue).
Using DwmGetColorizationColor
works, but the color is darker because I need to eliminate alpha. I try to do it like this:
BYTE r = ((RED * ALPHA) + (255 * (255 - ALPHA))) / 255; // R' = (R * A) + (1 - A)
BYTE g = ((GREEN * ALPHA) + (255 * (255 - ALPHA))) / 255; // G' = (G * A) + (1 - A)
BYTE b = ((BLUE * ALPHA) + (255 * (255 - ALPHA))) / 255; // B' = (B * A) + (1 - A)
So, my problems are:
- I don't know how I can correctly convert the return color from ARGB to RGB
- I don't know how to get the inactive title bar color
EDIT: My ARGB to RGB code seems to work unless I set color intensity in Control Panel to max (because somehow alpha is 0, and the color is green) or min.
EDIT2: This is not a duplicate because this is specifically about W8+.