Author: gadamopoulos
Date: Wed Apr 26 13:55:19 2017
New Revision: 74411
URL: 
http://svn.reactos.org/svn/reactos?rev=74411&view=rev
Log:
[UXTHEME] -Fix some resource leaks.
Modified:
    trunk/reactos/dll/win32/uxtheme/themehooks.c
Modified: trunk/reactos/dll/win32/uxtheme/themehooks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/themehoo…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/themehooks.c        [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/themehooks.c        [iso-8859-1] Wed Apr 26 13:55:19
2017
@@ -60,6 +60,8 @@
     if (pContext->hTabBackgroundBrush != NULL)
     {
+        CloseThemeData(GetWindowTheme(hWnd));
+
         DeleteObject(pContext->hTabBackgroundBrush);
         pContext->hTabBackgroundBrush = NULL;
     }
@@ -281,7 +283,7 @@
         {
             return OnPostWinPosChanged(hWnd, (WINDOWPOS*)lParam);
         }
-        case WM_DESTROY:
+        case WM_NCDESTROY:
         {
             ThemeDestroyWndContext(hWnd);
             return 0;
@@ -304,10 +306,6 @@
         HBITMAP hbmp;
         RECT dummy, bmpRect;
         BOOL hasImageAlpha;
-        //HTHEME theme = GetWindowTheme(hwnd);
-        theme = MSSTYLES_OpenThemeClass(ActiveThemeFile, NULL, L"TAB");
-        if (!theme)
-            return E_FAIL;
         UXTHEME_LoadImage(theme, 0, TABP_BODY, 0, &dummy, FALSE, &hbmp,
&bmpRect, &hasImageAlpha);
         if (changeOrigin)
@@ -384,7 +382,7 @@
             HWND hwndTarget = (HWND)lParam;
             HDC hdc = (HDC)wParam;
             HBRUSH* phbrush = (HBRUSH*)ret;
-            HTHEME theme = GetWindowTheme ( hWnd );
+            HTHEME hTheme;
             if (!IsAppThemed())
                 break;
@@ -392,7 +390,14 @@
             if (!IsThemeDialogTextureEnabled (hWnd))
                 break;
-            GetDiaogTextureBrush(theme, hwndTarget, hdc, phbrush, Msg != WM_CTLCOLORDLG);
+            hTheme = GetWindowTheme(hWnd);
+            if (!hTheme)
+                hTheme = OpenThemeData(hWnd, L"TAB");
+
+            if (!hTheme)
+                break;
+
+            GetDiaogTextureBrush(hTheme, hwndTarget, hdc, phbrush, Msg !=
WM_CTLCOLORDLG);
 #if 1
             {
@@ -491,7 +496,7 @@
     puah->DefWndProcArray.Size = UAHOWP_MAX_SIZE;
     puah->WndProcArray.MsgBitArray = gabMSGPmessages;
     puah->WndProcArray.Size = UAHOWP_MAX_SIZE;
-    puah->DlgProcArray.MsgBitArray = gabMSGPmessages;
+    puah->DlgProcArray.MsgBitArray = gabDLGPmessages;
     puah->DlgProcArray.Size = UAHOWP_MAX_SIZE;
     puah->SetWindowRgn = ThemeSetWindowRgn;