[PATCH 4/7] comctl32: Use OpenThemeDataForDpi() to create a theme handle not associated to a window.

Nikolay Sivov nsivov at codeweavers.com
Wed Sep 1 03:07:18 CDT 2021



On 9/1/21 9:37 AM, Zhiyi Zhang wrote:
> 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>
> ---
>  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);
For datetime/hotkey we don't have Edit controls internally, so that
makes sense.
>  
> 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;
>  }
Would it be bad to associate with toolbar window in this case, since
theme class is for Toolbar specifically?



More information about the wine-devel mailing list