[v2 PATCH] comctl32/trackbar: Scale thumb size with resolution.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/trackbar.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c index d774823d60..7cb73ca682 100644 --- a/dlls/comctl32/trackbar.c +++ b/dlls/comctl32/trackbar.c @@ -1468,25 +1468,28 @@ TRACKBAR_SetUnicodeFormat (TRACKBAR_INFO *infoPtr, BOOL fUnicode) return bTemp; } +static int get_scaled_metric(const TRACKBAR_INFO *infoPtr, int value) +{ + return MulDiv(value, GetDpiForWindow(infoPtr->hwndSelf), 96); +} static LRESULT TRACKBAR_InitializeThumb (TRACKBAR_INFO *infoPtr) { + int client_size; RECT rect; - int clientWidth, clientMetric; - /* initial thumb length */ - clientMetric = (infoPtr->dwStyle & TBS_ENABLESELRANGE) ? 23 : 21; + infoPtr->uThumbLen = get_scaled_metric(infoPtr, infoPtr->dwStyle & TBS_ENABLESELRANGE ? 23 : 21); + GetClientRect(infoPtr->hwndSelf,&rect); - if (infoPtr->dwStyle & TBS_VERT) { - clientWidth = rect.right - rect.left; - } else { - clientWidth = rect.bottom - rect.top; - } - if (clientWidth >= clientMetric) - infoPtr->uThumbLen = clientMetric; + if (infoPtr->dwStyle & TBS_VERT) + client_size = rect.right - rect.left; else - infoPtr->uThumbLen = clientWidth > 9 ? clientWidth - 6 : 4; + client_size = rect.bottom - rect.top; + + if (client_size < infoPtr->uThumbLen) + infoPtr->uThumbLen = client_size > get_scaled_metric(infoPtr, 9) ? + client_size - get_scaled_metric(infoPtr, 5) : get_scaled_metric(infoPtr, 4); TRACKBAR_CalcChannel (infoPtr); TRACKBAR_UpdateThumb (infoPtr); -- 2.18.0
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/user32/button.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/user32/button.c b/dlls/user32/button.c index 7684e7f2fa..9255a46343 100644 --- a/dlls/user32/button.c +++ b/dlls/user32/button.c @@ -842,8 +842,8 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action ) GetClientRect(hwnd, &client); rbox = rtext = client; - checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1; - checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1; + checkBoxWidth = 12 * GetDpiForWindow( hwnd ) / 96 + 1; + checkBoxHeight = 12 * GetDpiForWindow( hwnd ) / 96 + 1; if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); GetCharWidthW( hDC, '0', '0', &text_offset ); -- 2.18.0
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/button.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index 507820cf45..56968f99e3 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -1092,8 +1092,8 @@ static void CB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action ) GetClientRect(infoPtr->hwnd, &client); rbox = rtext = client; - checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1; - checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1; + checkBoxWidth = 12 * GetDpiForWindow( infoPtr->hwnd ) / 96 + 1; + checkBoxHeight = 12 * GetDpiForWindow( infoPtr->hwnd ) / 96 + 1; if ((hFont = infoPtr->font)) SelectObject( hDC, hFont ); GetCharWidthW( hDC, '0', '0', &text_offset ); -- 2.18.0
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 463189954e..856a0b39bf 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -316,8 +316,8 @@ static void taskdialog_get_radio_button_size(struct taskdialog_info *dialog_info hfont = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); old_hfont = SelectObject(hdc, hfont); - radio_box_width = 12 * GetDeviceCaps(hdc, LOGPIXELSX) / 96 + 1; - radio_box_height = 12 * GetDeviceCaps(hdc, LOGPIXELSY) / 96 + 1; + radio_box_width = 12 * GetDpiForWindow(hwnd) / 96 + 1; + radio_box_height = 12 * GetDpiForWindow(hwnd) / 96 + 1; GetCharWidthW(hdc, '0', '0', &text_offset); text_offset /= 2; -- 2.18.0
participants (1)
-
Nikolay Sivov