I'm trying to get the default Windows system background color in COLORREF
format with this code:
LOGBRUSH lb;
GetObject((HANDLE)(COLOR_BACKGROUND), sizeof(LOGBRUSH), &lb);
BG_COLOR = lb.lbColor;
char buff[250];
sprintf(buff, "BG_COLOR: 0x%08X;", BG_COLOR);
MessageBoxA(0, buff, "Alert!", MB_OK | MB_SYSTEMMODAL);
But it returns 0x003E28F4
which is red while setting a Window's class hbrBackground
as (HBRUSH)COLOR_BACKGROUND
like this:
WndClass.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
The background color for the window appears as grey (on WinXP) with hex 0x00C8D0D4
(checked with gimp).
As far as I know, 0x003E28F4
and 0x00C8D0D4
are not the same
What is causing this? How can I get the default background color in RGB/COLORREF format?
(HBRUSH)COLOR_BACKGROUND-1
? - Qix - MONICA WAS MISTREATEDGetObject
withCOLOR_BACKGROUND
, it can only be used withWndClass.hbrBackground
and therefore returns rubbish. Besides you need to add 1 to it - user1773602