GetScrollPos function (winuser.h)
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.
Syntax
int GetScrollPos(
[in] HWND hWnd,
[in] int nBar
);
Parameters
[in] hWnd
Type: HWND
Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
[in] nBar
Type: int
Specifies the scroll bar to be examined. This parameter can be one of the following values.
Return value
Type: int
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, SetScrollRange, GetScrollPos, and GetScrollRange support 32-bit scroll bar position data. Thus, an application can call GetScrollPos while processing either the WM_HSCROLL or WM_VSCROLL messages to obtain 32-bit scroll bar position data.
To get the 32-bit position of the scroll box (thumb) during a SB_THUMBTRACK request code in a WM_HSCROLL or WM_VSCROLL message, use the GetScrollInfo function.
If the nBar parameter is SB_CTL and the window specified by the hWnd parameter is not a system scroll bar control, the system sends the SBM_GETPOS message to the window to obtain scroll bar information. This allows GetScrollPos to operate on a custom control that mimics a scroll bar. If the window does not handle the SBM_GETPOS message, the GetScrollPos function fails.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
API set | ext-ms-win-ntuser-misc-l1-2-0 (introduced in Windows 8.1) |
See also
Reference