Adding the WS_CLIPCHILDREN
style bit to the parent window made this issue go away.
For whatever reason, when a window is partly obscured and then revealed, the OS is very generous with the WM_ERASEBKGND
messages and very stingy with the WM_PAINT
messages. What was happening is that the parent's WM_ERASEBKGND
handler was erasing over top of my control. Adding WS_CLIPCHILDREN
causes the parent window to clip its erasing.
Funnily enough, this solution worked for my control, which simply ignores the WM_ERASEBKGND
message, but didn't work for standard BUTTON
controls with style BS_GROUPBOX
style. I expect this is because of the same generous WM_ERASEBKGND
policy. The standard button control probably dutifully erases its background in handling that message and then vainly waits around for a WM_PAINT
message.