No DC_BRUSH can not be zero AND valid.
Originally Posted by megafiddle
HBRUSH is a HANDLE or pointer (memory address) so can not be NULL and valid.
In DEBUG mode (as opposed to Release mode build) the hBrush is probably initialised to NULL by the IDE.
FillRect() would call SelectObject() and probably is coded not to allow a NULL GDI object to be selected into a DC (as then the DC would throw errors when it tried to use the non existent GDI object).
//why is the PAINTSTUCT static?
HDC hdcPaint = BeginPaint(hWnd, &ps);
FillRect(hDc, &ps.rcPaint, hBrush);
FillRect(ps.hdc, &ps.rcPaint, GetStockObject(WHITE_BRUSH));
FillRect(hdcPaint , &ps.rcPaint, GetStockObject(WHITE_BRUSH));
//then there is no need to create or clean up any GDI objects
Other events generate WM_PAINT msgs (ie another window crossing yours) with differing invalidated rects in the PAINTSTRUCT so your code will not always draw the way you expect.