This documentation is archived and is not being maintained.


Sets minimum and maximum position values for the given scroll bar.

void SetScrollRange( 
   int nBar, 
   int nMinPos, 
   int nMaxPos, 
   BOOL bRedraw = TRUE  


Specifies the scroll bar to be set. This parameter can be either of the following values:

  • SB_HORZ   Sets the range of the horizontal scroll bar of the window.

  • SB_VERT   Sets the range of the vertical scroll bar of the window.


Specifies the minimum scrolling position.


Specifies the maximum scrolling position.


Specifies whether the scroll bar should be redrawn to reflect the change. If bRedraw is TRUE, the scroll bar is redrawn; if FALSE, the scroll bar is not redrawn.

It can also be used to hide or show standard scroll bars.

An application should not call this function to hide a scroll bar while processing a scroll-bar notification message.

If the call to SetScrollRange immediately follows a call to the SetScrollPos member function, the bRedraw parameter in the SetScrollPos member function should be 0 to prevent the scroll bar from being drawn twice.

The default range for a standard scroll bar is 0 through 100. The default range for a scroll bar control is empty (both the nMinPos and nMaxPos values are 0). The difference between the values specified by nMinPos and nMaxPos must not be greater than INT_MAX.

Header: afxwin.h