1.8.2 Scroll-Bar Thumb

The scroll-bar thumb is the small rectangle in a scroll bar. It shows the approximate location within the current document or file of the data currently displayed in the client area. For example, the thumb is in the middle of the scroll bar when page three of a five-page document is in the client area.

The SetScrollPos function sets the thumb position in a scroll bar. Since Windows does not automatically update the thumb position when an application scrolls, SetScrollPos must be used to update the thumb position. The GetScrollPos function retrieves the current position.

A thumb position is an integer. The position is relative to the left or upper end of the scroll bar, depending on whether the scroll bar is horizontal or vertical. The position must be within the scroll-bar range, which is defined by minimum and maximum values. The positions are distributed equally along the scroll bar. For example, if the range is 0 to 100, there are 100 positions along the scroll bar, each equally spaced so that position 50 is in the middle of the scroll bar. The initial range depends on the scroll bar. Standard scroll bars have an initial range of 0 to 100; scroll-bar controls have an empty range (both minimum and maximum values are zero) if no explicit range is given when the control is created. The SetScrollRange function sets new minimum and maximum values so that applications can change the range at any time. The GetScrollRange function retrieves the current minimum and maximum values. The minimum and maximum values can be any integers. For example, a spreadsheet program with 255 rows can set the vertical scroll range to 1 to 255.

If SetScrollPos specifies a position value that is less than the minimum or
more than the maximum, the minimum or maximum value is used instead.
SetScrollPos moves the thumb along the thumb positions.