Commit 0528f37f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserFindWindowEx implementation from user32.

parent 12cb04fd
......@@ -738,65 +738,24 @@ BOOL WINAPI OpenIcon( HWND hwnd )
/***********************************************************************
* FindWindowExW (USER32.@)
*/
HWND WINAPI FindWindowExW( HWND parent, HWND child, LPCWSTR className, LPCWSTR title )
HWND WINAPI FindWindowExW( HWND parent, HWND child, const WCHAR *class, const WCHAR *title )
{
HWND *list;
HWND retvalue = 0;
int i = 0, len = 0;
WCHAR *buffer = NULL;
if (!parent && child) parent = GetDesktopWindow();
else if (parent == HWND_MESSAGE) parent = get_hwnd_message_parent();
UNICODE_STRING class_str, title_str;
if (title)
{
len = lstrlenW(title) + 1; /* one extra char to check for chars beyond the end */
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return 0;
}
if (title) RtlInitUnicodeString( &title_str, title );
if (className)
if (class)
{
UNICODE_STRING str;
if (IS_INTRESOURCE(className))
if (IS_INTRESOURCE(class))
{
str.Buffer = (WCHAR *)className;
str.Length = str.MaximumLength = 0;
}
else RtlInitUnicodeString( &str, className );
list = list_window_children( 0, parent, &str, 0 );
class_str.Buffer = (WCHAR *)class;
class_str.Length = class_str.MaximumLength = 0;
}
else list = list_window_children( 0, parent, NULL, 0 );
if (!list) goto done;
if (child)
{
child = WIN_GetFullHandle( child );
while (list[i] && list[i] != child) i++;
if (!list[i]) goto done;
i++; /* start from next window */
else RtlInitUnicodeString( &class_str, class );
}
if (title)
{
while (list[i])
{
if (NtUserInternalGetWindowText( list[i], buffer, len + 1 ))
{
if (!wcsicmp( buffer, title )) break;
}
else
{
if (!title[0]) break;
}
i++;
}
}
retvalue = list[i];
done:
HeapFree( GetProcessHeap(), 0, list );
HeapFree( GetProcessHeap(), 0, buffer );
return retvalue;
return NtUserFindWindowEx( parent, child, class ? &class_str : NULL,
title ? &title_str : NULL, 0 );
}
......
......@@ -116,6 +116,7 @@ static void * const syscalls[] =
NtUserCreateWindowStation,
NtUserDestroyAcceleratorTable,
NtUserFindExistingCursorIcon,
NtUserFindWindowEx,
NtUserGetAncestor,
NtUserGetAtomName,
NtUserGetClassName,
......
......@@ -882,7 +882,7 @@
@ stdcall NtUserExcludeUpdateRgn(long long)
@ stub NtUserFillWindow
@ stdcall -syscall NtUserFindExistingCursorIcon(ptr ptr ptr)
@ stub NtUserFindWindowEx
@ stdcall -syscall NtUserFindWindowEx(long long ptr ptr long)
@ stdcall NtUserFlashWindowEx(ptr)
@ stub NtUserForceWindowToDpiForTest
@ stub NtUserFrostCrashedWindow
......
......@@ -2513,6 +2513,55 @@ NTSTATUS WINAPI NtUserBuildHwndList( HDESK desktop, ULONG unk2, ULONG unk3, ULON
return STATUS_SUCCESS;
}
/***********************************************************************
* NtUserFindWindowEx (USER32.@)
*/
HWND WINAPI NtUserFindWindowEx( HWND parent, HWND child, UNICODE_STRING *class, UNICODE_STRING *title,
ULONG unk )
{
HWND *list;
HWND retvalue = 0;
int i = 0, len = 0, title_len;
WCHAR *buffer = NULL;
if (!parent && child) parent = get_desktop_window();
else if (parent == HWND_MESSAGE) parent = get_hwnd_message_parent();
if (title)
{
len = title->Length / sizeof(WCHAR) + 1; /* one extra char to check for chars beyond the end */
if (!(buffer = malloc( (len + 1) * sizeof(WCHAR) ))) return 0;
}
if (!(list = list_window_children( 0, parent, class, 0 ))) goto done;
if (child)
{
child = get_full_window_handle( child );
while (list[i] && list[i] != child) i++;
if (!list[i]) goto done;
i++; /* start from next window */
}
if (title)
{
while (list[i])
{
title_len = NtUserInternalGetWindowText( list[i], buffer, len + 1 );
if (title_len * sizeof(WCHAR) == title->Length &&
(!title_len || !wcsnicmp( buffer, title->Buffer, title_len )))
break;
i++;
}
}
retvalue = list[i];
done:
free( list );
free( buffer );
return retvalue;
}
/* Retrieve the window text from the server. */
static data_size_t get_server_window_text( HWND hwnd, WCHAR *text, data_size_t count )
{
......
......@@ -103,6 +103,7 @@
SYSCALL_ENTRY( NtUserCreateWindowStation ) \
SYSCALL_ENTRY( NtUserDestroyAcceleratorTable ) \
SYSCALL_ENTRY( NtUserFindExistingCursorIcon ) \
SYSCALL_ENTRY( NtUserFindWindowEx ) \
SYSCALL_ENTRY( NtUserGetAncestor ) \
SYSCALL_ENTRY( NtUserGetAtomName ) \
SYSCALL_ENTRY( NtUserGetClassName ) \
......
......@@ -259,6 +259,22 @@ NTSTATUS WINAPI wow64_NtUserBuildHwndList( UINT *args )
return status;
}
NTSTATUS WINAPI wow64_NtUserFindWindowEx( UINT *args )
{
HWND parent = get_handle( &args );
HWND child = get_handle( &args );
UNICODE_STRING32 *class32 = get_ptr( &args );
UNICODE_STRING32 *title32 = get_ptr( &args );
ULONG unk = get_ulong( &args );
UNICODE_STRING class, title;
HWND ret;
ret = NtUserFindWindowEx( parent, child, unicode_str_32to64( &class, class32 ),
unicode_str_32to64( &title, title32 ), unk );
return HandleToUlong( ret );
}
NTSTATUS WINAPI wow64_NtUserInternalGetWindowText( UINT *args )
{
HWND hwnd = get_handle( &args );
......
......@@ -458,6 +458,8 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode,
INT WINAPI NtUserExcludeUpdateRgn( HDC hdc, HWND hwnd );
HICON WINAPI NtUserFindExistingCursorIcon( UNICODE_STRING *module, UNICODE_STRING *res_name,
void *desc );
HWND WINAPI NtUserFindWindowEx( HWND parent, HWND child, UNICODE_STRING *class,
UNICODE_STRING *title, ULONG unk );
BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info );
HWND WINAPI NtUserGetAncestor( HWND hwnd, UINT type );
SHORT WINAPI NtUserGetAsyncKeyState( INT key );
......
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