I've got a few layered windows in my app that use UpdateLayeredWindow()
to handle their visual representation. According to the MSDN article on layered windows, "when using UpdateLayeredWindow()
the application doesn't need to respond to WM_PAINT
or other painting messages." They shared some of the same message handlers as non-layered windows, so I figured I would just return early from WM_PAINT
handling if the target is a layered window.
Of course, this caused one major issue: if one of the layered windows did get a WM_PAINT
message, the input queue would end up flooded with an unending stream of WM_PAINT
messages. This end-result makes sense, since the window would never be validated and so it will keep thinking it needs to paint (I shouldn't be returning from the handler without validating or BeginPaint()
ing, etc.), but what doesn't make sense is why it received the message in the first place, since it has no effect on a window that was using UpdateLayeredWindow()
.
It wouldn't even happen reliably -- just every now and then, and not every time the window's pixels needed redrawing. Sanity was restored by falling back to DefWindowProc()
when a layered window got a WM_PAINT
message, but I feel like something is going on that I don't understand. And considering how seldom this problem manifested itself, I'm worried this might just be hiding an even subtler problem. Is it expected behavior for a window using UpdateLayeredWindow()
to still get the occasional WM_PAINT
message? Does it matter, as long as I handle it correctly?
Additional info, if needed: the window is calling UpdateLayeredWindow()
immediately after being created, and then it's left on its own (it doesn't call it again, since it doesn't change). Using C++ and win32 API, no MFC.