سؤال

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