Export (0) Print
Expand All

GetScrollRange function

The GetScrollRange function retrieves the current minimum and maximum scroll box (thumb) positions for the specified scroll bar.

Note  The GetScrollRange function is provided for compatibility only. New applications should use the GetScrollInfo function.

Syntax


BOOL GetScrollRange(
  _In_   HWND hWnd,
  _In_   int nBar,
  _Out_  LPINT lpMinPos,
  _Out_  LPINT lpMaxPos
);

Parameters

hWnd [in]

Type: HWND

Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.

nBar [in]

Type: int

Specifies the scroll bar from which the positions are retrieved. This parameter can be one of the following values.

ValueMeaning
SB_CTL

Retrieves the positions of a scroll bar control. The hWnd parameter must be the handle to the scroll bar control.

SB_HORZ

Retrieves the positions of the window's standard horizontal scroll bar.

SB_VERT

Retrieves the positions of the window's standard vertical scroll bar.

 

lpMinPos [out]

Type: LPINT

Pointer to the integer variable that receives the minimum position.

lpMaxPos [out]

Type: LPINT

Pointer to the integer variable that receives the maximum position.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If the specified window does not have standard scroll bars or is not a scroll bar control, the GetScrollRange function copies zero to the lpMinPos and lpMaxPos parameters.

The default range for a standard scroll bar is 0 through 100. The default range for a scroll bar control is empty (both values are zero).

The messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL, are limited to 16 bits of position data. However, because SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange 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 the GetScrollInfo function for a description of the technique.

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_GETRANGE message to the window to obtain scroll bar information. This allows GetScrollRange to operate on a custom control that mimics a scroll bar. If the window does not handle the SBM_GETRANGE message, the GetScrollRange function fails.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
GetScrollInfo
GetScrollPos
SetScrollInfo
SetScrollPos
SetScrollRange
WM_HSCROLL
WM_VSCROLL

 

 

Community Additions

ADD
Show:
© 2014 Microsoft