slj
2008-11-10 12:06:12 UTC
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;
}
'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;
}