From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/class.c | 2 +- dlls/user32/user_private.h | 1 + dlls/user32/win.c | 34 ++++++++++------------------------ 3 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c index b51783da64e..24e3b1e9200 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -120,7 +120,7 @@ static BOOL is_builtin_class( const WCHAR *name ) return FALSE; }
-static void init_class_name_ansi( UNICODE_STRING *str, const char *name ) +void init_class_name_ansi( UNICODE_STRING *str, const char *name ) { if (IS_INTRESOURCE( name )) { diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 2cb54211db6..900bf4a4424 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -82,6 +82,7 @@ extern void winproc_init(void); extern LRESULT dispatch_win_proc_params( struct win_proc_params *params );
extern void init_class_name( UNICODE_STRING *str, const WCHAR *name ); +extern void init_class_name_ansi( UNICODE_STRING *str, const char *name ); extern void get_class_version( UNICODE_STRING *name, UNICODE_STRING *version, BOOL load );
/* kernel callbacks */ diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 18866ac694e..330b827f0a3 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -511,19 +511,11 @@ BOOL WINAPI OpenIcon( HWND hwnd ) */ HWND WINAPI FindWindowExW( HWND parent, HWND child, const WCHAR *class, const WCHAR *title ) { - UNICODE_STRING class_str, title_str; + WCHAR class_nameW[MAX_ATOM_LEN + 1]; + UNICODE_STRING class_str = RTL_CONSTANT_STRING(class_nameW), title_str;
if (title) RtlInitUnicodeString( &title_str, title ); - - if (class) - { - if (IS_INTRESOURCE(class)) - { - class_str.Buffer = (WCHAR *)class; - class_str.Length = class_str.MaximumLength = 0; - } - else RtlInitUnicodeString( &class_str, class ); - } + if (class) init_class_name( &class_str, class );
return NtUserFindWindowEx( parent, child, class ? &class_str : NULL, title ? &title_str : NULL, 0 ); @@ -545,9 +537,10 @@ HWND WINAPI FindWindowA( LPCSTR className, LPCSTR title ) /*********************************************************************** * FindWindowExA (USER32.@) */ -HWND WINAPI FindWindowExA( HWND parent, HWND child, LPCSTR className, LPCSTR title ) +HWND WINAPI FindWindowExA( HWND parent, HWND child, const char *class, const char *title ) { - LPWSTR titleW = NULL; + WCHAR *titleW = NULL, class_nameW[MAX_ATOM_LEN + 1]; + UNICODE_STRING class_str = RTL_CONSTANT_STRING(class_nameW), title_str; HWND hwnd = 0;
if (title) @@ -555,19 +548,12 @@ HWND WINAPI FindWindowExA( HWND parent, HWND child, LPCSTR className, LPCSTR tit DWORD len = MultiByteToWideChar( CP_ACP, 0, title, -1, NULL, 0 ); if (!(titleW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0; MultiByteToWideChar( CP_ACP, 0, title, -1, titleW, len ); + RtlInitUnicodeString( &title_str, titleW ); } + if (class) init_class_name_ansi( &class_str, class );
- if (!IS_INTRESOURCE(className)) - { - WCHAR classW[256]; - if (MultiByteToWideChar( CP_ACP, 0, className, -1, classW, ARRAY_SIZE( classW ))) - hwnd = FindWindowExW( parent, child, classW, titleW ); - } - else - { - hwnd = FindWindowExW( parent, child, (LPCWSTR)className, titleW ); - } - + hwnd = NtUserFindWindowEx( parent, child, class ? &class_str : NULL, + title ? &title_str : NULL, 0 ); HeapFree( GetProcessHeap(), 0, titleW ); return hwnd; }