Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function sets the minimum and maximum position values for the specified scroll bar. It can also be used to hide or show a standard scroll bar. SetScrollRangeis provided for compatibility with Windows 3. x. Win32-based applications should use the SetScrollInfofunction.
BOOL SetScrollRange( HWND hWnd , int nBar , int nMinPos , int nMaxPos , BOOL bRedraw );
Parameters
Value | Description |
---|---|
SB_CTL | Sets the range of a scroll bar control. The hWndparameter must be the handle to the scroll bar control. |
SB_HORZ | Sets the range of a window's standard horizontal scroll bar. |
SB_VERT | Sets the range of a window's standard vertical scroll bar. |
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
Remarks
You can use SetScrollRangeto hide the scroll bar by setting nMinPosand nMaxPosto the same value. An application should not call the SetScrollRangefunction to hide a scroll bar while processing a scroll bar message.
If the call to SetScrollRangeimmediately follows a call to the SetScrollPosfunction, the bRedrawparameter in SetScrollPosmust be zero to prevent the scroll bar from being drawn twice.
The default range for a standard scroll bar or a scroll bar control is 0 through 100. The difference between the values specified by the nMinPosand nMaxPosparameters must not be greater than the value of MAXLONG.
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 SetScrollRangefunction's nMaxPosparameter.
However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRangefunctions 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 GetScrollInfofor 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