From 38e715387da75458874a22efb34419cc469f9624 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 8 May 2018 01:30:52 +0300 Subject: [PATCH] comctl32/trackbar: Fix reseting to default page size. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/tests/trackbar.c | 11 +++++++++++ dlls/comctl32/trackbar.c | 31 +++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c index 7d66df775ec..7f17e9e4b68 100644 --- a/dlls/comctl32/tests/trackbar.c +++ b/dlls/comctl32/tests/trackbar.c @@ -613,6 +613,17 @@ static void test_page_size(void) r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0); ok(r == 10, "Unexpected page size %d.\n", r); + r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -1); + ok(r == 10, "Unexpected page size %d.\n", r); + + r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0); + ok(r == 7, "Unexpected page size %d.\n", r); + + SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, 0, 100); + + r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0); + ok(r == 19, "Unexpected page size %d.\n", r); + DestroyWindow(hWndTrackbar); hWndTrackbar = create_trackbar(defaultstyle, hWndParent); diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c index 762d2e1376e..d774823d609 100644 --- a/dlls/comctl32/trackbar.c +++ b/dlls/comctl32/trackbar.c @@ -1196,18 +1196,30 @@ TRACKBAR_SetLineSize (TRACKBAR_INFO *infoPtr, LONG lLineSize) return lTemp; } +static void TRACKBAR_UpdatePageSize(TRACKBAR_INFO *infoPtr) +{ + if (infoPtr->flags & TB_USER_PAGE) + return; + + infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5; + if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1; +} static inline LONG TRACKBAR_SetPageSize (TRACKBAR_INFO *infoPtr, LONG lPageSize) { LONG lTemp = infoPtr->lPageSize; - if (lPageSize != -1) - infoPtr->lPageSize = lPageSize; + if (lPageSize == -1) + { + infoPtr->flags &= ~TB_USER_PAGE; + TRACKBAR_UpdatePageSize(infoPtr); + } else - infoPtr->lPageSize = TB_DEFAULTPAGESIZE; - - infoPtr->flags |= TB_USER_PAGE; + { + infoPtr->flags |= TB_USER_PAGE; + infoPtr->lPageSize = lPageSize; + } return lTemp; } @@ -1234,15 +1246,6 @@ TRACKBAR_SetPos (TRACKBAR_INFO *infoPtr, BOOL fPosition, LONG lPosition) return 0; } -static void TRACKBAR_UpdatePageSize(TRACKBAR_INFO *infoPtr) -{ - if (infoPtr->flags & TB_USER_PAGE) - return; - - infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5; - if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1; -} - static inline LRESULT TRACKBAR_SetRange (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG range) {