Zhiyi Zhang : comctl32: Use OpenThemeDataForDpi() to create a theme handle not associated to a window.

Alexandre Julliard julliard at winehq.org
Wed Sep 1 15:45:09 CDT 2021


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

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Sep  1 14:37:46 2021 +0800

comctl32: Use OpenThemeDataForDpi() to create a theme handle not associated to a window.

If a window is not passed to OpenThemeData(), OpenThemeData() assumes the DPI is 96 according to
tests. And GetThemePartSize() should select theme parts according to the DPI stored in theme
handles rather than using GDI device contexts. Thus, OpenThemeDataForDpi() should be used in place
of OpenThemeData() when DPI is not 96 and theme handles shouldn't be associated with a window.

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

---

 dlls/comctl32/datetime.c | 2 +-
 dlls/comctl32/hotkey.c   | 2 +-
 dlls/comctl32/toolbar.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index ac5268f146c..f8827d4e26c 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -1317,7 +1317,7 @@ static LRESULT DATETIME_NCPaint (HWND hwnd, HRGN region)
     RECT r;
     HDC dc;
 
-    theme = OpenThemeData(NULL, WC_EDITW);
+    theme = OpenThemeDataForDpi(NULL, WC_EDITW, GetDpiForWindow(hwnd));
     if (!theme)
         return DefWindowProcW(hwnd, WM_NCPAINT, (WPARAM)region, 0);
 
diff --git a/dlls/comctl32/hotkey.c b/dlls/comctl32/hotkey.c
index 7421ff6ef65..7808660e7f5 100644
--- a/dlls/comctl32/hotkey.c
+++ b/dlls/comctl32/hotkey.c
@@ -434,7 +434,7 @@ HOTKEY_NCPaint (HWND hwnd, HRGN region)
     RECT r;
     HDC dc;
 
-    theme = OpenThemeData(NULL, WC_EDITW);
+    theme = OpenThemeDataForDpi(NULL, WC_EDITW, GetDpiForWindow(hwnd));
     if (!theme)
         return DefWindowProcW(hwnd, WM_NCPAINT, (WPARAM)region, 0);
 
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index cf1dc42449b..2ae70ad4f3e 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -5313,7 +5313,7 @@ TOOLBAR_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
 
     SystemParametersInfoW (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
     infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW (&logFont);
-    infoPtr->hTheme = OpenThemeData (NULL, themeClass);
+    infoPtr->hTheme = OpenThemeDataForDpi (NULL, themeClass, GetDpiForWindow (hwnd));
 
     TOOLBAR_CheckStyle (infoPtr);
 
@@ -6550,7 +6550,7 @@ TOOLBAR_SysColorChange (void)
 static LRESULT theme_changed (TOOLBAR_INFO *infoPtr)
 {
     CloseThemeData (infoPtr->hTheme);
-    infoPtr->hTheme = OpenThemeData (NULL, themeClass);
+    infoPtr->hTheme = OpenThemeDataForDpi (NULL, themeClass, GetDpiForWindow (infoPtr->hwndSelf));
     InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
     return 0;
 }




More information about the wine-cvs mailing list