[UXTHEME] Fix a series of problems regarding ThemeCalculateCaptionButtonsPos
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Mon, 7 Jan 2019 09:38:42 +0000 (11:38 +0200)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Mon, 7 Jan 2019 09:38:42 +0000 (11:38 +0200)
Only call it when needed. Also make it fail properly if the window theme could not be opened.
CORE-15564

dll/win32/uxtheme/nonclient.c
dll/win32/uxtheme/themehooks.c

index 4171e09..1ff26a3 100644 (file)
@@ -230,7 +230,11 @@ void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme)
         return;
 
     if (!htheme)
-        htheme = pwndData->hthemeWindow;
+    {
+        htheme = GetNCCaptionTheme(hWnd, style);
+        if (!htheme)
+            return;
+    }
 
     if(!GetWindowInfo(hWnd, &wi))
         return;
index 9981180..583fce3 100644 (file)
@@ -323,7 +323,8 @@ ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR
         case WM_SIZE:
         case WM_WINDOWPOSCHANGED:
         {
-            ThemeCalculateCaptionButtonsPos(hWnd, NULL);
+            if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
+                ThemeCalculateCaptionButtonsPos(hWnd, NULL);
             break;
         }
         case WM_THEMECHANGED:
@@ -360,7 +361,11 @@ ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR
                 pwndData->hthemeScrollbar = NULL;
             }
 
-            ThemeCalculateCaptionButtonsPos(hWnd, NULL);
+            if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
+                ThemeCalculateCaptionButtonsPos(hWnd, NULL);
+
+            pwndData->DirtyThemeRegion = TRUE;
+            break;
         }
         case WM_NCCREATE:
         {