A little sample to demonstrate how to paint the background instead of allowing Windows to erase it. This paints different system colours across the window - see the colour list starting at
COLOR_SCROLLBAR
in
WinUser.h.
BOOL Cls_OnEraseBkgnd(HWND hWnd,
HDC hDC
)
{
HBRUSH hBrush;
RECT rectClient;
int nWidth;
GetClientRect(hWnd, &rectClient);
nWidth = rectClient.right / 30;
rectClient.right = 1;
for (int nBrush = 0; nBrush <= 30; ++nBrush)
{
hBrush = GetSysColorBrush(nBrush);
rectClient.right += nWidth;
FillRect(hDC, &rectClient, hBrush);
rectClient.left += nWidth;
}
return TRUE;
}