comctl32/trackbar: Update thumb on range change.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-07-14 23:39:53 +03:00 committed by Alexandre Julliard
parent 099eda8ead
commit cd55d74742
2 changed files with 31 additions and 8 deletions

View File

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

View File

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