Skip to content

Commit

Permalink
comctl32/trackbar: Fix reseting to default page size.
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Sivov <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
nsivov authored and julliard committed May 8, 2018
1 parent 0aead09 commit 38e7153
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
11 changes: 11 additions & 0 deletions dlls/comctl32/tests/trackbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 17 additions & 14 deletions dlls/comctl32/trackbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)
{
Expand Down

0 comments on commit 38e7153

Please sign in to comment.