I realized that I need also the pressed state, so, I changed the code accordingly as follow:
if (hTheme)
{
HDC hDCTest = CreateCompatibleDC(hDC);
HBITMAP hBitmapTest = CreateCompatibleBitmap(hDC, nWidth, nHeight);
HBITMAP hBitmapTestOld = (HBITMAP)SelectObject(hDCTest, hBitmapTest);
RECT rectTest = { 0, 0, rect.right - rect.left, nHeight };
DrawThemeBackground(hTheme, hDCTest, HP_HEADERITEM, HIS_NORMAL, &rectTest, NULL);
clrBackground = GetPixel(hDCTest, 1, 1);
DrawThemeBackground(hTheme, hDCTest, HP_HEADERITEM, HIS_HOT, &rectTest, NULL);
clrBackgroundHot = GetPixel(hDCTest, 1, 1);
DrawThemeBackground(hTheme, hDCTest, HP_HEADERITEM, HIS_PRESSED, &rectTest, NULL);
clrBackgroundPress = GetPixel(hDCTest, 1, 1);
SelectObject(hDCTest, hBitmapTestOld);
DeleteObject(hBitmapTest);
DeleteDC(hDCTest);
}
and
HDC hDCTemp = CreateCompatibleDC(hDC);
HBITMAP hBitmapTemp = CreateCompatibleBitmap(hDC, nWidth, nHeight);
HBITMAP hBitmapTempOld = (HBITMAP)SelectObject(hDCTemp, hBitmapTemp);
// White => Yellow
TransparentBlt(hDC, 0, 0, nWidth, nHeight, hDCMem, 0, 0, nWidth, nHeight, clrBackground);
BitBlt(hDCTemp, 0, 0, nWidth, nHeight, hDC, 0, 0, SRCCOPY);
// Green brush
HBRUSH hBrushHot = CreateSolidBrush(RGB(0, 255, 0));
HBRUSH hBrushHotOld = (HBRUSH)SelectObject(hDC, hBrushHot);
FillRect(hDC, &rect, hBrushHot);
SelectObject(hDC, hBrushHotOld);
DeleteObject(hBrushHot);
// Light Blue => Green
TransparentBlt(hDC, 0, 0, nWidth, nHeight, hDCTemp, 0, 0, nWidth, nHeight, clrBackgroundHot);
// Red brush
HBRUSH hBrushPressed = CreateSolidBrush(RGB(255, 0, 0));
HBRUSH hBrushPressedOld = (HBRUSH)SelectObject(hDC, hBrushPressed);
FillRect(hDC, &rect, hBrushPressed);
SelectObject(hDC, hBrushPressedOld);
DeleteObject(hBrushPressed);
// Green => Red
TransparentBlt(hDC, 0, 0, nWidth, nHeight, hDCTemp, 0, 0, nWidth, nHeight, clrBackgroundPress);
SelectObject(hDCTemp, hBitmapTempOld);
DeleteObject(hBitmapTemp);
DeleteDC(hDCTemp);
but now the hot state is not working.
I have tried to use a second hTempDC, but didn't work either. Is there possible to achive the pressed state beside hot state ? If it is, how ?