Today, a quick puzzler.
Consider the following code fragment:
ShowWindow(hwnd, SW_SHOWNORMAL); assert(IsWindowVisible(hwnd));
We just showed the window, certainly it is visible, right? Yet the assertion can fire (even in the absence of multi-threading). Why?
Answer below - stop reading if you want to try to solve it yourself.
Take a look at
If the specified window, its parent window, its parent's parent window, and so forth, have the
WS_VISIBLEstyle, the return value is nonzero. Otherwise, the return value is zero.
WS_VISIBLE style indicates that this window is
visible in its parent. But the parent itself might not be visible,
in which case
[Raymond is currently on vacation; this message was pre-recorded.]