From 35ed21d27aa23fb318a00a769b945f48193f23a5 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Mon, 7 Feb 2022 16:09:45 +0800 Subject: [PATCH] comctl32/treeview: Support HiDPI for unthemed item check boxes. Signed-off-by: Zhiyi Zhang Signed-off-by: Alexandre Julliard --- dlls/comctl32/treeview.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index 608ce489e33..e9e2cb37d47 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -3011,30 +3011,34 @@ static BOOL TREEVIEW_InitThemedCheckboxes(TREEVIEW_INFO *info) static void TREEVIEW_InitCheckboxes(TREEVIEW_INFO *infoPtr) { + int nIndex, width, height; RECT rc; HBITMAP hbm, hbmOld; HDC hdc, hdcScreen; - int nIndex; if (TREEVIEW_InitThemedCheckboxes(infoPtr)) return; - infoPtr->himlState = ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0); + width = 12 * GetDpiForWindow(infoPtr->hwnd) / 96 + 1; + height = width; + infoPtr->himlState = ImageList_Create(width, height, ILC_COLOR | ILC_MASK, 3, 0); hdcScreen = GetDC(0); hdc = CreateCompatibleDC(hdcScreen); - hbm = CreateCompatibleBitmap(hdcScreen, 48, 16); + hbm = CreateCompatibleBitmap(hdcScreen, width * 3, height); hbmOld = SelectObject(hdc, hbm); - SetRect(&rc, 0, 0, 48, 16); + SetRect(&rc, 0, 0, width * 3, height); FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW+1)); - SetRect(&rc, 18, 2, 30, 14); + rc.left = width; + rc.right = rc.left + width; DrawFrameControl(hdc, &rc, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_FLAT); - SetRect(&rc, 34, 2, 46, 14); + rc.left = width * 2; + rc.right = rc.left + width; DrawFrameControl(hdc, &rc, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED); @@ -3047,8 +3051,8 @@ TREEVIEW_InitCheckboxes(TREEVIEW_INFO *infoPtr) DeleteDC(hdc); ReleaseDC(0, hdcScreen); - infoPtr->stateImageWidth = 16; - infoPtr->stateImageHeight = 16; + infoPtr->stateImageWidth = width; + infoPtr->stateImageHeight = height; } static void