diff --git a/dlls/user/win.c b/dlls/user/win.c index 68d6bb0d8d..592eeace8a 100644 --- a/dlls/user/win.c +++ b/dlls/user/win.c @@ -249,7 +249,6 @@ static HWND *list_window_children( HWND hwnd, ATOM atom, DWORD tid ) * * Build an array of all parents of a given window, starting with * the immediate parent. The array must be freed with HeapFree. - * Returns NULL if window is a top-level window. */ static HWND *list_window_parents( HWND hwnd ) { @@ -2611,14 +2610,17 @@ BOOL WINAPI IsChild( HWND parent, HWND child ) BOOL WINAPI IsWindowVisible( HWND hwnd ) { HWND *list; - BOOL retval; + BOOL retval = TRUE; int i; if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) return FALSE; if (!(list = list_window_parents( hwnd ))) return TRUE; - for (i = 0; list[i]; i++) - if (!(GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE)) break; - retval = !list[i]; + if (list[0] && list[1]) /* desktop window is considered always visible so we don't check it */ + { + for (i = 0; list[i+1]; i++) + if (!(GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE)) break; + retval = !list[i+1]; + } HeapFree( GetProcessHeap(), 0, list ); return retval; } @@ -2634,7 +2636,7 @@ BOOL WINAPI IsWindowVisible( HWND hwnd ) BOOL WIN_IsWindowDrawable( HWND hwnd, BOOL icon ) { HWND *list; - BOOL retval; + BOOL retval = TRUE; int i; LONG style = GetWindowLongW( hwnd, GWL_STYLE ); @@ -2642,10 +2644,13 @@ BOOL WIN_IsWindowDrawable( HWND hwnd, BOOL icon ) if ((style & WS_MINIMIZE) && icon && GetClassLongPtrW( hwnd, GCLP_HICON )) return FALSE; if (!(list = list_window_parents( hwnd ))) return TRUE; - for (i = 0; list[i]; i++) - if ((GetWindowLongW( list[i], GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != WS_VISIBLE) - break; - retval = !list[i]; + if (list[0] && list[1]) /* desktop window is considered always visible so we don't check it */ + { + for (i = 0; list[i+1]; i++) + if ((GetWindowLongW( list[i], GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != WS_VISIBLE) + break; + retval = !list[i+1]; + } HeapFree( GetProcessHeap(), 0, list ); return retval; }