Zhiyi Zhang : comctl32/ipaddress: Do not open theme data in IPADDRESS_Draw().

Alexandre Julliard julliard at winehq.org
Wed Mar 3 15:47:30 CST 2021


Module: wine
Branch: master
Commit: 79516685817d5d0f1004c37260b8ba330c316d98
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=79516685817d5d0f1004c37260b8ba330c316d98

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Mar  3 14:49:00 2021 +0800

comctl32/ipaddress: Do not open theme data in IPADDRESS_Draw().

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/ipaddress.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/ipaddress.c b/dlls/comctl32/ipaddress.c
index c7b9ada1f6a..b6302a89ba6 100644
--- a/dlls/comctl32/ipaddress.c
+++ b/dlls/comctl32/ipaddress.c
@@ -145,7 +145,7 @@ static LRESULT IPADDRESS_Draw (const IPADDRESS_INFO *infoPtr, HDC hdc)
 
     GetClientRect (infoPtr->Self, &rect);
 
-    theme = OpenThemeData(infoPtr->Self, WC_EDITW);
+    theme = GetWindowTheme (infoPtr->Self);
 
     if (theme) {
         DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
@@ -193,9 +193,6 @@ static LRESULT IPADDRESS_Draw (const IPADDRESS_INFO *infoPtr, HDC hdc)
             DrawTextW(hdc, L".", 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
     }
 
-    if (theme)
-        CloseThemeData(theme);
-
     return 0;
 }
 
@@ -255,6 +252,7 @@ static LRESULT IPADDRESS_Create (HWND hwnd, const CREATESTRUCTA *lpCreate)
     }
 
     IPADDRESS_UpdateText (infoPtr);
+    OpenThemeData (infoPtr->Self, WC_EDITW);
 
     return 0;
 }
@@ -262,6 +260,7 @@ static LRESULT IPADDRESS_Create (HWND hwnd, const CREATESTRUCTA *lpCreate)
 
 static LRESULT IPADDRESS_Destroy (IPADDRESS_INFO *infoPtr)
 {
+    HTHEME theme;
     int i;
 
     TRACE("\n");
@@ -272,6 +271,8 @@ static LRESULT IPADDRESS_Destroy (IPADDRESS_INFO *infoPtr)
     }
 
     SetWindowLongPtrW (infoPtr->Self, 0, 0);
+    theme = GetWindowTheme (infoPtr->Self);
+    CloseThemeData (theme);
     heap_free (infoPtr);
     return 0;
 }
@@ -456,6 +457,13 @@ static BOOL IPADDRESS_GotoNextField (const IPADDRESS_INFO *infoPtr, int cur, int
     return FALSE;
 }
 
+static LRESULT IPADDRESS_ThemeChanged (const IPADDRESS_INFO *infoPtr)
+{
+    HTHEME theme = GetWindowTheme (infoPtr->Self);
+    CloseThemeData (theme);
+    theme = OpenThemeData (theme, WC_EDITW);
+    return 0;
+}
 
 /*
  * period: move and select the text in the next field to the right if
@@ -618,6 +626,9 @@ IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
             COMCTL32_RefreshSysColors();
             return 0;
 
+        case WM_THEMECHANGED:
+            return IPADDRESS_ThemeChanged (infoPtr);
+
         case IPM_CLEARADDRESS:
             return IPADDRESS_ClearAddress (infoPtr);
 




More information about the wine-cvs mailing list