Question

I'm attempting to clear part of my screen with

FillRect(hdc, &r, (HBRUSH)(WHITE_BRUSH))

However it "succeeds" (returns nonzero) but writes nothing to the screen. If I change it to

FillRect(hdc, &r, (HBRUSH)(WHITE_BRUSH+1))

it magically starts working, except now it's clearing the screen with a slight gray color. Is there something I am missing here?

Was it helpful?

Solution

The brush constants are not guaranteed to be valid handles; you're supposed to use GetStockObject to convert the constant to a handle. It's probably just a coincidence that WHITE_BRUSH+1 evaluates to something that appears to work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top