Commit 7dfdf5a5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

user32: Use get_class_info for GetClasInfoEx implementation.

parent 5e75e5f6
...@@ -402,36 +402,6 @@ static const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_of ...@@ -402,36 +402,6 @@ static const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_of
} }
/*********************************************************************** /***********************************************************************
* CLASS_FindClass
*
* Return a pointer to the class.
*/
static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance, UNICODE_STRING *name_str )
{
CLASS *class;
if (name != (LPCWSTR)DESKTOP_CLASS_ATOM && (IS_INTRESOURCE(name) || wcsicmp( name, L"Message" )))
GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
if (!name) return NULL;
name = CLASS_GetVersionedName( name, NULL, NULL, TRUE );
while (!(class = find_class( hinstance, name )))
{
if (IS_INTRESOURCE( name )) break;
if (!is_comctl32_class( name )) break;
if (GetModuleHandleW( L"comctl32.dll" )) break;
if (!LoadLibraryW( L"comctl32.dll" )) break;
TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
}
if (!class) TRACE("%s %p -> not found\n", debugstr_w(name), hinstance);
else if (name_str) init_class_name( name_str, name );
return class;
}
/***********************************************************************
* CLASS_RegisterClass * CLASS_RegisterClass
* *
* The real RegisterClass() functionality. * The real RegisterClass() functionality.
...@@ -1264,17 +1234,52 @@ BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc ) ...@@ -1264,17 +1234,52 @@ BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
return ret; return ret;
} }
ATOM get_class_info( HINSTANCE instance, const WCHAR *name, UNICODE_STRING *name_str ) ATOM get_class_info( HINSTANCE instance, const WCHAR *name, WNDCLASSEXW *info,
UNICODE_STRING *name_str, BOOL ansi )
{ {
CLASS *class; CLASS *class;
ATOM atom; ATOM atom;
if (!(class = CLASS_FindClass( name, instance, name_str ))) if (!name_str && !instance) instance = user32_module;
if (name != (LPCWSTR)DESKTOP_CLASS_ATOM && (IS_INTRESOURCE(name) || wcsicmp( name, L"Message" )))
GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
name = CLASS_GetVersionedName( name, NULL, NULL, TRUE );
while (name && !(class = find_class( instance, name )))
{
if (IS_INTRESOURCE( name )) break;
if (!is_comctl32_class( name )) break;
if (GetModuleHandleW( L"comctl32.dll" )) break;
if (!LoadLibraryW( L"comctl32.dll" )) break;
TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
}
if (!class)
{ {
TRACE("%s %p -> not found\n", debugstr_w(name), instance);
SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
return FALSE; return 0;
}
if (info)
{
info->style = class->style;
info->lpfnWndProc = WINPROC_GetProc( class->winproc, !ansi );
info->cbClsExtra = class->cbClsExtra;
info->cbWndExtra = class->cbWndExtra;
info->hInstance = (instance == user32_module) ? 0 : instance;
info->hIcon = class->hIcon;
info->hIconSm = class->hIconSm ? class->hIconSm : class->hIconSmIntern;
info->hCursor = class->hCursor;
info->hbrBackground = class->hbrBackground;
info->lpszMenuName = ansi ? (const WCHAR *)CLASS_GetMenuNameA( class )
: CLASS_GetMenuNameW( class );
info->lpszClassName = name;
} }
if (name_str) init_class_name( name_str, name );
atom = class->atomName; atom = class->atomName;
release_class_ptr( class ); release_class_ptr( class );
return atom; return atom;
...@@ -1286,7 +1291,6 @@ ATOM get_class_info( HINSTANCE instance, const WCHAR *name, UNICODE_STRING *name ...@@ -1286,7 +1291,6 @@ ATOM get_class_info( HINSTANCE instance, const WCHAR *name, UNICODE_STRING *name
BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc ) BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
{ {
ATOM atom; ATOM atom;
CLASS *classPtr;
TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc); TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
...@@ -1296,35 +1300,15 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc ) ...@@ -1296,35 +1300,15 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
return FALSE; return FALSE;
} }
if (!hInstance) hInstance = user32_module;
if (!IS_INTRESOURCE(name)) if (!IS_INTRESOURCE(name))
{ {
WCHAR nameW[MAX_ATOM_LEN + 1]; WCHAR nameW[MAX_ATOM_LEN + 1];
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW ))) if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW )))
return FALSE; return FALSE;
classPtr = CLASS_FindClass( nameW, hInstance, NULL ); atom = get_class_info( hInstance, nameW, (WNDCLASSEXW *)wc, NULL, TRUE );
}
else classPtr = CLASS_FindClass( (LPCWSTR)name, hInstance, NULL );
if (!classPtr)
{
SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
return FALSE;
} }
wc->style = classPtr->style; else atom = get_class_info( hInstance, (const WCHAR *)name, (WNDCLASSEXW *)wc, NULL, TRUE );
wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE ); if (atom) wc->lpszClassName = name;
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
wc->hIcon = classPtr->hIcon;
wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
wc->hCursor = classPtr->hCursor;
wc->hbrBackground = classPtr->hbrBackground;
wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
wc->lpszClassName = name;
atom = classPtr->atomName;
release_class_ptr( classPtr );
/* We must return the atom of the class here instead of just TRUE. */ /* We must return the atom of the class here instead of just TRUE. */
return atom; return atom;
...@@ -1336,9 +1320,6 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc ) ...@@ -1336,9 +1320,6 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
*/ */
BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc ) BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc )
{ {
ATOM atom;
CLASS *classPtr;
TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc); TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
if (!wc) if (!wc)
...@@ -1347,29 +1328,7 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc ...@@ -1347,29 +1328,7 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
return FALSE; return FALSE;
} }
if (!hInstance) hInstance = user32_module; return get_class_info( hInstance, name, wc, NULL, FALSE );
if (!(classPtr = CLASS_FindClass( name, hInstance, NULL )))
{
SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
return FALSE;
}
wc->style = classPtr->style;
wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
wc->hIcon = classPtr->hIcon;
wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
wc->hCursor = classPtr->hCursor;
wc->hbrBackground = classPtr->hbrBackground;
wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
wc->lpszClassName = name;
atom = classPtr->atomName;
release_class_ptr( classPtr );
/* We must return the atom of the class here instead of just TRUE. */
return atom;
} }
......
...@@ -160,7 +160,8 @@ extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar ...@@ -160,7 +160,8 @@ extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN; LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
extern void winproc_init(void) DECLSPEC_HIDDEN; extern void winproc_init(void) DECLSPEC_HIDDEN;
extern ATOM get_class_info( HINSTANCE instance, const WCHAR *name, UNICODE_STRING *name_str ) DECLSPEC_HIDDEN; extern ATOM get_class_info( HINSTANCE instance, const WCHAR *name, WNDCLASSEXW *info,
UNICODE_STRING *name_str, BOOL ansi ) DECLSPEC_HIDDEN;
/* kernel callbacks */ /* kernel callbacks */
......
...@@ -1402,7 +1402,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, ...@@ -1402,7 +1402,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
CBT_CREATEWNDW cbtc; CBT_CREATEWNDW cbtc;
CREATESTRUCTW cbcs; CREATESTRUCTW cbcs;
if (!get_class_info( module, className, &class )) return FALSE; if (!get_class_info( module, className, NULL, &class, FALSE )) return FALSE;
TRACE("%s %s%s%s ex=%08x style=%08x %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n", TRACE("%s %s%s%s ex=%08x style=%08x %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n",
unicode ? debugstr_w(cs->lpszName) : debugstr_a((LPCSTR)cs->lpszName), unicode ? debugstr_w(cs->lpszName) : debugstr_a((LPCSTR)cs->lpszName),
......
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