ScrollBar_SetPage


Description:
The following allows you to change the page size of a scroll bar, so you can make the thumb of a scroll bar larger to match the size of the document being viewed.
 
Code:
Private Type SCROLLINFO
    cbSize As Long
    fMask As Long
    nMin As Long
    nMax As Long
    nPage As Long
    nPos As Long
    nTrackPos As Long
End Type

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long

Private Const SBM_SETSCROLLINFO = &HE9
Private Const SBM_GETSCROLLINFO = &HEA
Private Const SIF_RANGE = &H1
Private Const SIF_PAGE = &H2
Private Const SIF_POS = &H4
Private Const SIF_DISABLENOSCROLL = &H8
Private Const SIF_TRACKPOS = &H10
Private Const SIF_ALL = SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS

Private Sub ScrollBar_SetPage(ScrollBar As Object, nPage As Long)

    Dim si As SCROLLINFO
    si.cbSize = Len(si)
    si.fMask = SIF_ALL
    SendMessage ScrollBar.hwnd, SBM_GETSCROLLINFO, 0, si
    si.nPage = si.nMax / ((ScrollBar.Max - ScrollBar.Min) / nPage)
    SendMessage ScrollBar.hwnd, SBM_SETSCROLLINFO, 1, si

End Sub
 
Sample Usage:
 
    ScrollBar_SetPage HScroll1, 750