Commit 9b9f97e3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

user32: Add redirected class registration callback.

parent fe572072
...@@ -194,5 +194,6 @@ ...@@ -194,5 +194,6 @@
@ stdcall PropertySheet(ptr) PropertySheetA @ stdcall PropertySheet(ptr) PropertySheetA
@ stdcall PropertySheetA(ptr) @ stdcall PropertySheetA(ptr)
@ stdcall PropertySheetW(ptr) @ stdcall PropertySheetW(ptr)
@ stdcall RegisterClassNameW(wstr)
@ stdcall UninitializeFlatSB(long) @ stdcall UninitializeFlatSB(long)
@ stdcall _TrackMouseEvent(ptr) @ stdcall _TrackMouseEvent(ptr)
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include "shlwapi.h" #include "shlwapi.h"
#include "comctl32.h" #include "comctl32.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(commctrl); WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
...@@ -113,6 +114,40 @@ static void unregister_versioned_classes(void) ...@@ -113,6 +114,40 @@ static void unregister_versioned_classes(void)
#undef VERSION #undef VERSION
} }
BOOL WINAPI RegisterClassNameW(const WCHAR *class)
{
static const struct
{
const WCHAR nameW[16];
void (*fn_register)(void);
}
classes[] =
{
{ {'B','u','t','t','o','n',0}, BUTTON_Register },
{ {'C','o','m','b','o','B','o','x',0}, COMBO_Register },
{ {'C','o','m','b','o','L','B','o','x',0}, COMBOLBOX_Register },
{ {'E','d','i','t',0}, EDIT_Register },
{ {'L','i','s','t','B','o','x',0}, LISTBOX_Register },
{ {'S','t','a','t','i','c',0}, STATIC_Register },
};
int min = 0, max = ARRAY_SIZE(classes) - 1;
while (min <= max)
{
int res, pos = (min + max) / 2;
if (!(res = strcmpiW(class, classes[pos].nameW)))
{
classes[pos].fn_register();
return TRUE;
}
if (res < 0) max = pos - 1;
else min = pos + 1;
}
return FALSE;
}
/*********************************************************************** /***********************************************************************
* DllMain [Internal] * DllMain [Internal]
* *
...@@ -172,13 +207,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -172,13 +207,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
TREEVIEW_Register (); TREEVIEW_Register ();
UPDOWN_Register (); UPDOWN_Register ();
BUTTON_Register ();
COMBO_Register ();
COMBOLBOX_Register ();
EDIT_Register ();
LISTBOX_Register ();
STATIC_Register ();
/* subclass user32 controls */ /* subclass user32 controls */
THEMING_Initialize (); THEMING_Initialize ();
break; break;
......
...@@ -320,7 +320,7 @@ static void CLASS_FreeClass( CLASS *classPtr ) ...@@ -320,7 +320,7 @@ static void CLASS_FreeClass( CLASS *classPtr )
USER_Unlock(); USER_Unlock();
} }
const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset ) const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset, BOOL register_class )
{ {
ACTCTX_SECTION_KEYED_DATA data; ACTCTX_SECTION_KEYED_DATA data;
struct wndclass_redirect_data struct wndclass_redirect_data
...@@ -332,7 +332,8 @@ const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset ) ...@@ -332,7 +332,8 @@ const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset )
ULONG module_len; ULONG module_len;
ULONG module_offset; ULONG module_offset;
} *wndclass; } *wndclass;
const WCHAR *module; const WCHAR *module, *ret;
HMODULE hmod;
if (basename_offset) if (basename_offset)
*basename_offset = 0; *basename_offset = 0;
...@@ -352,10 +353,42 @@ const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset ) ...@@ -352,10 +353,42 @@ const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset )
*basename_offset = wndclass->name_len / sizeof(WCHAR) - strlenW(name); *basename_offset = wndclass->name_len / sizeof(WCHAR) - strlenW(name);
module = (const WCHAR *)((BYTE *)data.lpSectionBase + wndclass->module_offset); module = (const WCHAR *)((BYTE *)data.lpSectionBase + wndclass->module_offset);
if (!GetModuleHandleW( module )) if (!(hmod = GetModuleHandleW( module )))
LoadLibraryW( module ); hmod = LoadLibraryW( module );
return (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset); ret = (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset);
if (register_class && hmod)
{
BOOL found = FALSE;
struct list *ptr;
USER_Lock();
LIST_FOR_EACH( ptr, &class_list )
{
CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
if (strcmpiW( class->name, ret )) continue;
if (!class->local || class->hInstance == hmod)
{
found = TRUE;
break;
}
}
USER_Unlock();
if (!found)
{
BOOL (WINAPI *pRegisterClassNameW)(const WCHAR *class);
pRegisterClassNameW = (void *)GetProcAddress(hmod, "RegisterClassNameW");
if (pRegisterClassNameW)
pRegisterClassNameW(name);
}
}
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -373,7 +406,7 @@ static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance ) ...@@ -373,7 +406,7 @@ static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
if (!name) return NULL; if (!name) return NULL;
name = CLASS_GetVersionedName( name, NULL ); name = CLASS_GetVersionedName( name, NULL, TRUE );
for (;;) for (;;)
{ {
...@@ -409,7 +442,6 @@ static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance ) ...@@ -409,7 +442,6 @@ static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
return NULL; return NULL;
} }
/*********************************************************************** /***********************************************************************
* CLASS_RegisterClass * CLASS_RegisterClass
* *
...@@ -646,7 +678,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc ) ...@@ -646,7 +678,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
{ {
UINT basename_offset; UINT basename_offset;
if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0; if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0;
classname = CLASS_GetVersionedName( name, &basename_offset ); classname = CLASS_GetVersionedName( name, &basename_offset, FALSE );
classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS), classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
wc->style, wc->cbClsExtra, wc->cbWndExtra ); wc->style, wc->cbClsExtra, wc->cbWndExtra );
} }
...@@ -700,7 +732,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc ) ...@@ -700,7 +732,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
} }
if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL ); if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset ); classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset, FALSE );
if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS), if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
wc->style, wc->cbClsExtra, wc->cbWndExtra ))) wc->style, wc->cbClsExtra, wc->cbWndExtra )))
return 0; return 0;
...@@ -753,7 +785,7 @@ BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance ) ...@@ -753,7 +785,7 @@ BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */ GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
className = CLASS_GetVersionedName( className, NULL ); className = CLASS_GetVersionedName( className, NULL, FALSE );
SERVER_START_REQ( destroy_class ) SERVER_START_REQ( destroy_class )
{ {
req->instance = wine_server_client_ptr( hInstance ); req->instance = wine_server_client_ptr( hInstance );
......
...@@ -269,7 +269,8 @@ extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM w ...@@ -269,7 +269,8 @@ extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM w
extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN; LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
extern const WCHAR *CLASS_GetVersionedName(const WCHAR *classname, UINT *basename_offset) DECLSPEC_HIDDEN; extern const WCHAR *CLASS_GetVersionedName(const WCHAR *classname, UINT *basename_offset,
BOOL register_class) DECLSPEC_HIDDEN;
/* message spy definitions */ /* message spy definitions */
......
...@@ -1344,7 +1344,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, ...@@ -1344,7 +1344,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
CBT_CREATEWNDW cbtc; CBT_CREATEWNDW cbtc;
CREATESTRUCTW cbcs; CREATESTRUCTW cbcs;
className = CLASS_GetVersionedName(className, NULL); className = CLASS_GetVersionedName(className, NULL, TRUE);
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