Ok, I figured it out...
for your wndclass (or wndclassex) structure's hbrbackground, do this:
wndclass.hbrBackground = CreateSolidBrush(0);
then whenever you want to change it, call:
DeleteObject((HBRUSH)SetClassLong(hwnd, GCL_HBRBACKGROUND,
(LONG)CreateSolidBrush(RGB(255,0,0))));
you can change the RGB(255,0,0) to whatever RGB value you want.
here's an example program
Code:
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR pszCmdLine, int iShowCmd)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = CreateSolidBrush(0);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszMenuName = NULL;
wc.lpszClassName = "Colors!";
RegisterClass(&wc);
hWnd = CreateWindowEx(0, "Colors!",
"Pretty Colors", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, iShowCmd);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
DeleteObject((HBRUSH)SetClassLong(hwnd, GCL_HBRBACKGROUND,
(LONG)CreateSolidBrush(RGB(255,0,0))));
return 0;
case WM_CLOSE:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wParam,lParam);
}