xor
xor

Reputation: 93

HBRUSH to RGB value

Can you get the RGB value from HBRUSH or from brush id? for example: I'm looking for GRAY_BRUSH in RGB value.

Upvotes: 8

Views: 3597

Answers (2)

Khalfan Aziz
Khalfan Aziz

Reputation: 41

        static COLORREF lbColor;
        HBRUSH hb = GetSysColorBrush(COLOR_BACKGROUND);            
        LOGBRUSH br = { 0 };

        if (GetObject(hb, sizeof(br), &br))
        {
            lbColor = br.lbColor;

            RGBQUAD rgbq = { 0 };
            rgbq.rgbBlue = GetBValue(lbColor);
            rgbq.rgbGreen = GetGValue(lbColor);
            rgbq.rgbRed = GetRValue(lbColor);
            rgbq.rgbReserved = 0;
            //...
        }

Upvotes: 2

GSerg
GSerg

Reputation: 78174

You want to use the GetObject function to return a LOGBRUSH structure that contains the brush color.

Upvotes: 7

Related Questions