From cd55d747429980dea37295d0d6ce68e7b3c01686 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 14 Jul 2016 23:39:53 +0300 Subject: [PATCH] comctl32/trackbar: Update thumb on range change. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/tests/trackbar.c | 23 +++++++++++++++++++++++ dlls/comctl32/trackbar.c | 16 ++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c index adb1b126573..918cf1a3371 100644 --- a/dlls/comctl32/tests/trackbar.c +++ b/dlls/comctl32/tests/trackbar.c @@ -687,6 +687,7 @@ static void test_position(void) static void test_range(void) { HWND hWndTrackbar; + RECT rect1, rect2; int r; hWndTrackbar = create_trackbar(defaultstyle, hWndParent); @@ -752,6 +753,28 @@ static void test_range(void) ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE); ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE); + /* TBM_SETRANGE updates thumb visual position (rectangle) if needed */ + r = SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-10, 0)); + ok(r == 0, "got %d\n", r); + SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 0); + + RedrawWindow(hWndTrackbar, NULL, 0, RDW_UPDATENOW); + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1); + + r = SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-10, 10)); + ok(r == 0, "got %d\n", r); + RedrawWindow(hWndTrackbar, NULL, 0, RDW_UPDATENOW); + + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect2); + ok(!EqualRect(&rect1, &rect2), "thumb rectangle not updated\n"); + + /* change range back, don't force repaint */ + r = SendMessageA(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(-10, 0)); + ok(r == 0, "got %d\n", r); + + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1); + ok(EqualRect(&rect1, &rect2), "thumb rectangle not updated\n"); + DestroyWindow(hWndTrackbar); } diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c index 8c99ad093fb..f79cc67ffbf 100644 --- a/dlls/comctl32/trackbar.c +++ b/dlls/comctl32/trackbar.c @@ -1245,21 +1245,21 @@ TRACKBAR_SetRange (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG range) infoPtr->lRangeMin = (SHORT)LOWORD(range); infoPtr->lRangeMax = (SHORT)HIWORD(range); - if (infoPtr->lPos < infoPtr->lRangeMin) { + /* clip position to new min/max limit */ + if (infoPtr->lPos < infoPtr->lRangeMin) infoPtr->lPos = infoPtr->lRangeMin; - infoPtr->flags |= TB_THUMBPOSCHANGED; - } - if (infoPtr->lPos > infoPtr->lRangeMax) { + if (infoPtr->lPos > infoPtr->lRangeMax) infoPtr->lPos = infoPtr->lRangeMax; - infoPtr->flags |= TB_THUMBPOSCHANGED; - } infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5; if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1; - if (changed && (infoPtr->dwStyle & TBS_AUTOTICKS)) - TRACKBAR_RecalculateTics (infoPtr); + if (changed) { + if (infoPtr->dwStyle & TBS_AUTOTICKS) + TRACKBAR_RecalculateTics (infoPtr); + infoPtr->flags |= TB_THUMBPOSCHANGED; + } if (redraw) TRACKBAR_InvalidateAll(infoPtr);