Commit bfe6826a authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32: Return FALSE for invalid handle in IsWindowEnabled().

GetWindowLong() returns 0 if passed an invalid window handle, causing IsWindowEnabled() to incorrectly report TRUE. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0b69359a
......@@ -10700,6 +10700,27 @@ static void test_destroy_quit(void)
CloseHandle( thread1 );
}
static void test_IsWindowEnabled(void)
{
BOOL ret;
HWND hwnd;
ret = IsWindowEnabled(NULL);
ok(!ret, "Expect IsWindowEnabled() return FALSE\n");
hwnd = GetDesktopWindow();
ret = IsWindowEnabled(hwnd);
ok(ret, "Expect IsWindowEnabled() return TRUE\n");
hwnd = create_tool_window(WS_CHILD | WS_VISIBLE, hwndMain);
ret = IsWindowEnabled(hwnd);
ok(ret, "Expect IsWindowEnabled() return TRUE\n");
EnableWindow(hwnd, FALSE);
ret = IsWindowEnabled(hwnd);
ok(!ret, "Expect IsWindowEnabled() return FALSE\n");
DestroyWindow(hwnd);
}
START_TEST(win)
{
char **argv;
......@@ -10856,6 +10877,7 @@ START_TEST(win)
test_hide_window();
test_minimize_window(hwndMain);
test_destroy_quit();
test_IsWindowEnabled();
/* add the tests above this line */
if (hhook) UnhookWindowsHookEx(hhook);
......
......@@ -2157,9 +2157,13 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
*/
BOOL WINAPI IsWindowEnabled(HWND hWnd)
{
return !(GetWindowLongW( hWnd, GWL_STYLE ) & WS_DISABLED);
}
LONG ret;
SetLastError(NO_ERROR);
ret = GetWindowLongW( hWnd, GWL_STYLE );
if (!ret && GetLastError() != NO_ERROR) return FALSE;
return !(ret & WS_DISABLED);
}
/***********************************************************************
* IsWindowUnicode (USER32.@)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment