user32: Move module class registration to get_class_info.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-03-07 14:41:42 +01:00 committed by Alexandre Julliard
parent 7dfdf5a5ca
commit 18697bb7b5
1 changed files with 26 additions and 24 deletions

View File

@ -332,7 +332,8 @@ static CLASS *find_class( HINSTANCE module, const WCHAR *name )
return NULL;
}
static const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset, WCHAR *combined, BOOL register_class )
static const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset, WCHAR *combined,
HMODULE *reg_module )
{
ACTCTX_SECTION_KEYED_DATA data;
struct wndclass_redirect_data
@ -349,6 +350,7 @@ static const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_of
HMODULE hmod;
UINT offset;
if (reg_module) *reg_module = 0;
if (!basename_offset)
basename_offset = &offset;
@ -383,21 +385,7 @@ static const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_of
ret = combined;
}
if (register_class && hmod)
{
CLASS *class;
if (!(class = find_class( hmod, ret )))
{
BOOL (WINAPI *pRegisterClassNameW)(const WCHAR *class);
pRegisterClassNameW = (void *)GetProcAddress(hmod, "RegisterClassNameW");
if (pRegisterClassNameW)
pRegisterClassNameW(name);
}
else release_class_ptr( class );
}
if (reg_module) *reg_module = hmod;
return ret;
}
@ -1237,28 +1225,42 @@ BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
ATOM get_class_info( HINSTANCE instance, const WCHAR *name, WNDCLASSEXW *info,
UNICODE_STRING *name_str, BOOL ansi )
{
const WCHAR *class_name;
HMODULE module;
CLASS *class;
ATOM atom;
class_name = CLASS_GetVersionedName( name, NULL, NULL, &module );
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 )))
while (class_name && !(class = find_class( instance, class_name )))
{
if (IS_INTRESOURCE( name )) break;
if (!is_comctl32_class( name )) break;
if (module)
{
BOOL (WINAPI *pRegisterClassNameW)( const WCHAR *class );
pRegisterClassNameW = (void *)GetProcAddress( module, "RegisterClassNameW" );
module = NULL;
if (pRegisterClassNameW)
{
TRACE( "registering %s\n", debugstr_w(name) );
pRegisterClassNameW( name );
continue;
}
}
if (IS_INTRESOURCE( class_name )) break;
if (!is_comctl32_class( 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) );
TRACE( "%s retrying after loading comctl32\n", debugstr_w(class_name) );
}
if (!class)
{
TRACE("%s %p -> not found\n", debugstr_w(name), instance);
TRACE("%s %p -> not found\n", debugstr_w(class_name), instance);
SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
return 0;
}
@ -1279,7 +1281,7 @@ ATOM get_class_info( HINSTANCE instance, const WCHAR *name, WNDCLASSEXW *info,
info->lpszClassName = name;
}
if (name_str) init_class_name( name_str, name );
if (name_str) init_class_name( name_str, class_name );
atom = class->atomName;
release_class_ptr( class );
return atom;