I have this code to change the background of a window:
Code:
HBRUSH hBrush = NULL;
switch(LOWORD(wParam))
{
//
// ... some other stuff ...
//
case IDM_RED: hBrush = ::CreateSolidBrush(RGB(0xFF, 0x00, 0x00)); break;
case IDM_YELLOW: hBrush = ::CreateSolidBrush(RGB(0xFF, 0xFF, 0x00)); break;
case IDM_BLACK: hBrush = ::CreateSolidBrush(RGB(0x00, 0x00, 0x00)); break;
case IDM_WHITE: hBrush = ::CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF)); break;
case IDM_GREEN: hBrush = ::CreateSolidBrush(RGB(0x00, 0xFF, 0x00)); break;
case IDM_BLUE: hBrush = ::CreateSolidBrush(RGB(0x00, 0x00, 0xFF)); break;
}
if(hBrush)
{
::SetClassLong(hwnd, GCL_HBRBACKGROUND, (long) hBrush);
}
However, the background color only changes when I go away and come back to the window. MSDN warned of this sort of thing like delayed repainting or something, but I was not sure of a remedy. Also, it says that this function was superceded by SetClassLongPtr(..) but when I tried to use it it said it was undeclared even when I put
Code:
#define _WIN32_WINNT 0x501
#include <windows.h>
Any ideas for that?