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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-09-01 14:37:46 +08:00 committed by Alexandre Julliard
parent 615a90e219
commit 7be103bba9
3 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
}