Index: dll/win32/comctl32/comctl32.h
===================================================================
--- dll/win32/comctl32/comctl32.h	(revision 67704)
+++ dll/win32/comctl32/comctl32.h	(working copy)
@@ -165,7 +165,7 @@
 int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace) DECLSPEC_HIDDEN;
 LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second) DECLSPEC_HIDDEN;
 
-extern void THEMING_Initialize(void) DECLSPEC_HIDDEN;
+extern void THEMING_Initialize(HINSTANCE hInst) DECLSPEC_HIDDEN;
 extern void THEMING_Uninitialize(void) DECLSPEC_HIDDEN;
 extern LRESULT THEMING_CallOriginalClass(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
 extern void THEMING_SetSubclassData(HWND, ULONG_PTR) DECLSPEC_HIDDEN;
Index: dll/win32/comctl32/commctrl.c
===================================================================
--- dll/win32/comctl32/commctrl.c	(revision 67704)
+++ dll/win32/comctl32/commctrl.c	(working copy)
@@ -215,7 +215,7 @@
             UPDOWN_Register ();
 
             /* subclass user32 controls */
-            THEMING_Initialize ();
+            THEMING_Initialize (hinstDLL);
             break;
 
 	case DLL_PROCESS_DETACH:
Index: dll/win32/comctl32/theming.c
===================================================================
--- dll/win32/comctl32/theming.c	(revision 67704)
+++ dll/win32/comctl32/theming.c	(working copy)
@@ -108,7 +108,7 @@
  * Register classes for standard controls that will shadow the system
  * classes.
  */
-void THEMING_Initialize (void)
+void THEMING_Initialize (HINSTANCE hInst)
 {
     unsigned int i;
     static const WCHAR subclassPropName[] = 
@@ -134,6 +134,7 @@
         }
         originalProcs[i] = class.lpfnWndProc;
         class.lpfnWndProc = subclassProcs[i];
+        class.hInstance  = hInst;
         
         if (!class.lpfnWndProc)
         {
@@ -141,7 +142,8 @@
                 debugstr_w (subclasses[i].className));
             continue;
         }
-
+        class.style = CS_GLOBALCLASS;
+        
         if (!RegisterClassExW (&class))
         {
             ERR("Could not re-register class %s: %x\n",
Index: win32ss/user/ntuser/class.c
===================================================================
--- win32ss/user/ntuser/class.c	(revision 67704)
+++ win32ss/user/ntuser/class.c	(working copy)
@@ -1206,6 +1206,7 @@
 static PCLS
 IntFindClass(IN RTL_ATOM Atom,
              IN HINSTANCE hInstance,
+             IN BOOL IsSystem,
              IN PCLS *ClassList,
              OUT PCLS **Link  OPTIONAL)
 {
@@ -1215,14 +1216,33 @@
     while (Class != NULL)
     {
         if (Class->atomClassName == Atom &&
-            (hInstance == NULL || Class->hModule == hInstance) &&
             !(Class->CSF_flags & CSF_WOWDEFERDESTROY))
         {
             ASSERT(Class->pclsBase == Class);
-
-            if (Link != NULL)
-                *Link = PrevLink;
-            break;
+            if (!IsSystem)
+            {
+                if ((hInstance == NULL) && !(Class->hModule == NULL))
+                {
+                    if (Link != NULL)
+                        *Link = PrevLink;
+                    break;
+                }
+                else if (Class->hModule == hInstance)
+                {
+                    if (Link != NULL)
+                        *Link = PrevLink;
+                    break;
+                }
+            }
+            else
+            {
+                if  (Class->hModule == NULL)
+                {
+                    if (Link != NULL)
+                        *Link = PrevLink;
+                    break;
+                }
+            }
         }
 
         PrevLink = &Class->pclsNext;
@@ -1327,6 +1347,7 @@
         /* Step 1: Try to find an exact match of locally registered classes */
         Class = IntFindClass(Atom,
                              hInstance,
+                             FALSE,
                              &pi->pclsPrivateList,
                              Link);
         if (Class != NULL)
@@ -1337,7 +1358,8 @@
         /* Step 2: Try to find any globally registered class. The hInstance
                    is not relevant for global classes */
         Class = IntFindClass(Atom,
-                             NULL,
+                             NULL, 
+                             FALSE,
                              &pi->pclsPublicList,
                              Link);
         if (Class != NULL)
@@ -1347,7 +1369,8 @@
 
         /* Step 3: Try to find any local class registered by user32 */
         Class = IntFindClass(Atom,
-                             hModClient,
+                             NULL,
+                             TRUE,
                              &pi->pclsPrivateList,
                              Link);
         if (Class != NULL)
@@ -1357,7 +1380,8 @@
 
         /* Step 4: Try to find any global class registered by user32 */
         Class = IntFindClass(Atom,
-                             hModClient,
+                             NULL,
+                             TRUE,
                              &pi->pclsPublicList,
                              Link);
         if (Class == NULL)
@@ -1458,6 +1482,7 @@
     {
        Class = IntFindClass( ClassAtom,
                              lpwcx->hInstance,
+                             FALSE,
                             &pi->pclsPrivateList,
                              NULL);
 
@@ -1473,6 +1498,7 @@
        {
           Class = IntFindClass( ClassAtom,
                                 NULL,
+                                TRUE,
                                &pi->pclsPublicList,
                                 NULL);
 
