https://git.reactos.org/?p=reactos.git;a=commitdiff;h=88a69b446bd310e563185dcd4ec73bc29837485a

commit 88a69b446bd310e563185dcd4ec73bc29837485a
Author:     Giannis Adamopoulos <gadamopou...@reactos.org>
AuthorDate: Mon Jan 7 11:38:42 2019 +0200
Commit:     Giannis Adamopoulos <gadamopou...@reactos.org>
CommitDate: Mon Jan 7 11:38:42 2019 +0200

    [UXTHEME] Fix a series of problems regarding ThemeCalculateCaptionButtonsPos
    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  | 6 +++++-
 dll/win32/uxtheme/themehooks.c | 9 +++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c
index 4171e09264..1ff26a3218 100644
--- a/dll/win32/uxtheme/nonclient.c
+++ b/dll/win32/uxtheme/nonclient.c
@@ -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;
diff --git a/dll/win32/uxtheme/themehooks.c b/dll/win32/uxtheme/themehooks.c
index 99811808f7..583fce34d4 100644
--- a/dll/win32/uxtheme/themehooks.c
+++ b/dll/win32/uxtheme/themehooks.c
@@ -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:
         {

Reply via email to