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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top