The hollow brush

The hollow brush is a brush that doesn't do anything. You can use it when you're forced to use a brush but you don't want to.

As one example, you can use it as your class brush. Then when your program stops responding and Windows decide to do the "white flash" (see yesterday's entry), it grabs the hollow brush and ends up not drawing anything. (At least, that's how it worked on Windows 2000. Things may be different on XP.)

Another place you can use the hollow brush is when handling the WM_CTLCOLOR* messages. Those messages require you to return a brush, which will be used to erase the background. If you don't want to erase the background, a hollow brush does the trick.

While on the subject of brushes, what’s the benefit (apart from not having to call SelectObject all over the place) of using the new DC brush and pen objects DC_BRUSH and DC_PEN? Is it worth rewriting existing code?

MSDN is fine. The "hollow brush" and the "null brush" are just two names for the same thing. Note that the null brush is not same as the NULL pointer. There is of course history behind this double-naming: It used to be called the null brush, but that proved to be easily confused with (HBRUSH)NULL, so the new name "hollow brush" was invented. The old name remains for compatibility reasons.

The benefit of the DC pen and DC brush is that you don’t have all these brush and pen handles to worry about leaking. No reason to rewrite existing code.

Mr. Dimmick’s point about MSDN is that MSDN gives recursive definitions but fails to give a useful definition. Mr. Chen, you gave a definition which appears far more useful than MSDN, which appears like it ought to go into MSDN in addition to the present recursion. After seeing asdf’s reply I’m not sure exactly what to suggest, but Mr. Dimmick’s point still stands.

Err, my comment was about when the app doesn’t respond. And it’s a tiny bit wrong too, if the app was obscured by some other window and then becomes unobscured it will blit the background of the windows that were covering it before.