GetScrollPos
The GetScrollPos
function retrieves the current position of the scroll box (thumb) in the
specified scroll bar. The current position is a relative value that depends on
the current scrolling range. For example, if the scrolling range is 0 through
100 and the scroll box is in the middle of the bar, the current position is 50.
int GetScrollPos(
HWND hWnd, |
// handle of window
with scroll bar |
int nBar |
// scroll bar flags |
); |
|
Parameters
hWnd
Identifies a
scroll bar control or a window with a standard scroll bar, depending on the
value of the nBar parameter.
nBar
Specifies the
scroll bar to be examined. This parameter can be one of the following values:
Value |
Meaning |
SB_CTL |
Retrieves
the position of the scroll box in a scroll bar control. The hWnd
parameter must be the handle of the scroll bar control. |
SB_HORZ |
Retrieves
the position of the scroll box in a window s standard horizontal scroll bar. |
SB_VERT |
Retrieves
the position of the scroll box in a window s standard vertical scroll bar. |
Return Values
If the
function succeeds, the return value is the current position of the scroll box/
If the
function fails, the return value is zero. To get extended error information,
call GetLastError
Remarks
The GetScrollPos
function enables applications to use 32-bit scroll positions. Although the
messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL, are
limited to 16 bits of position data, the functions SetScrollPos
The
limitation on this technique applies to real-time scrolling of a window s
content. An application implements such scrolling by processing the WM_HSCROLL
or WM_VSCROLL messages that carry the SB_THUMBTRACK notification message,
thereby tracking the position of the scroll box, also known as the thumb, while
the user moves it. Unfortunately, there is no function to retrieve the thumb s
32-bit position while the user moves it. GetScrollPos provides static
position data only; an application can therefore only obtain 32-bit position
data before or after a scroll has taken place.
See Also