SetScrollPos
This function sets the position of the scroll box (thumb) in the specified scroll bar and, if requested, redraws the scroll bar to reflect the new position of the scroll box. SetScrollPos is provided for compatibility with Windows 3.x. Win32-based applications should use the SetScrollInfo function.
int SetScrollPos(
HWND hWnd,
int nBar,
int nPos,
BOOL bRedraw );
Parameters
hWnd
Handle to 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 set. This parameter can be one of the following values:Value Description SB_CTL Sets the position of the scroll box in a scroll bar control. The hWnd parameter must be the handle to the scroll bar control. SB_HORZ Sets the position of the scroll box in a windows standard horizontal scroll bar. SB_VERT Sets the position of the scroll box in a windows standard vertical scroll bar. nPos
Specifies the new position of the scroll box. The position must be within the scrolling range. For more information about the scrolling range, see the SetScrollRange function.bRedraw
Boolean that specifies whether the scroll bar is redrawn to reflect the new scroll box position. If this parameter is TRUE, the scroll bar is redrawn. If it is FALSE, the scroll bar is not redrawn.
Return Values
The previous position of the scroll box indicates success. Zero indicates failure. To get extended error information, call GetLastError.
Remarks
If the scroll bar is redrawn by a subsequent call to another function, setting the bRedraw parameter to FALSE is useful.
In Windows CE versions 2.12 and earlier, SetScrollPos returns the new position of the scroll bar.
Because the messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL, are limited to 16 bits of position data, applications that rely solely on those messages for position data have a practical maximum value of 65,535 for the SetScrollPos functions nPos parameter.
However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and WM_VSCROLL messages. See GetScrollInfo for a description of the technique.
Requirements
| Runs on | Versions | Defined in | Include | Link to |
|---|---|---|---|---|
| Windows CE OS | 2.0 and later | Winuser.h | Sbcmn.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetScrollInfo, ScrollDC, ScrollWindowEx, SetScrollRange
Last updated on Tuesday, July 13, 2004
© 1992-2000 Microsoft Corporation. All rights reserved.