user32: FindWindow() should treat an empty title same way as NULL.

This commit is contained in:
Dmitry Timoshkov 2010-10-19 14:22:53 +09:00 committed by Alexandre Julliard
parent b08d3d2656
commit 2f0b9dd3bf
2 changed files with 29 additions and 4 deletions

View File

@ -6239,15 +6239,31 @@ static void test_rtl_layout(void)
static void test_FindWindowEx(void)
{
HWND found;
HWND hwnd, found;
CHAR title[1];
hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
title[0] = 0;
found = FindWindowExA( 0, 0, "MainWindowClass", title );
ok( found == NULL, "expected a NULL hwnd\n" );
found = FindWindowExA( 0, 0, "MainWindowClass", NULL );
ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
DestroyWindow( hwnd );
hwnd = CreateWindowExA( 0, "MainWindowClass", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
found = FindWindowExA( 0, 0, "MainWindowClass", title );
ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
found = FindWindowExA( 0, 0, "MainWindowClass", NULL );
ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
DestroyWindow( hwnd );
/* test behaviour with a window title that is an empty character */
found = FindWindowExA( 0, 0, "Shell_TrayWnd", title );
todo_wine
@ -6307,6 +6323,9 @@ START_TEST(win)
hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
if (!hhook) win_skip( "Cannot set CBT hook, skipping some tests\n" );
/* make sure that FindWindow tests are executed first */
test_FindWindowEx();
hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
WS_MAXIMIZEBOX | WS_POPUP,
@ -6374,7 +6393,6 @@ START_TEST(win)
test_Expose();
test_layered_window();
test_FindWindowEx();
test_SetForegroundWindow(hwndMain);
test_shell_window();
test_handles( hwndMain );

View File

@ -1767,7 +1767,14 @@ HWND WINAPI FindWindowExW( HWND parent, HWND child, LPCWSTR className, LPCWSTR t
{
while (list[i])
{
if (GetWindowTextW( list[i], buffer, len + 1 ) && !strcmpiW( buffer, title )) break;
if (GetWindowTextW( list[i], buffer, len + 1 ))
{
if (!strcmpiW( buffer, title )) break;
}
else
{
if (!title[0]) break;
}
i++;
}
}