Discussion:
IsWindowVisible returning False even if window is actually visible? [Nbr. 2]
(too old to reply)
slj
2008-11-10 12:06:12 UTC
Permalink
This is an addendum to the thread
'IsWindowVisible returning False even if window is actually visible?'

We have had the same problem when calling IsWindowVisible in an
OnShowWindow-handler (actually in a method called by the OnShowWindow-
handler).

It seems that IsWindowVisible returns the old state when handling
ON_WM_SHOWWINDOW,
and returns the correct value when the next message is handled.

The code snippet below will give the following trace:

OnShowWindow: IsWindowVisible = No
OnTrace: IsWindowVisible = Yes

------------------------------ Code
--------------------------------------

BEGIN_MESSAGE_MAP(CMyWnd, CDialog)
...
ON_WM_SHOWWINDOW()
ON_MESSAGE(WM_USER+1, OnTrace)
END_MESSAGE_MAP


void CMyWnd::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);

TRACE("OnShowWindow: IsWindowVisible = %s\r\n",
IsWindowVisible()?"Yes":"No");
PostMessage(WM_USER+1);
}

LRESULT CMyWnd::OnTrace(WPARAM wParam, LPARAM lParam)
{
TRACE("OnTrace: IsWindowVisible = %s\r\n",
IsWindowVisible()?"Yes":"No");
return 0;
}
Alex Blekhman
2008-11-10 15:46:43 UTC
Permalink
Post by slj
It seems that IsWindowVisible returns the old state when
handling ON_WM_SHOWWINDOW, and returns the correct value when
the next message is handled.
This behaviour is perfectly consistent with WM_SHOWWINDOW
documentation:

<quote>
The WM_SHOWWINDOW message is sent to a window when the window is
about to be hidden or shown.
</quote>

HTH
Alex

Loading...