Partager via


CScrollBar::SetScrollRange

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

void SetScrollRange(
   int nMinPos,
   int nMaxPos,
   BOOL bRedraw = TRUE 
);

Parameters

  • nMinPos
    Specifies the minimum scrolling position.

  • nMaxPos
    Specifies the maximum scrolling position.

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

Remarks

Set nMinPos and nMaxPos to 0 to hide standard scroll bars.

Do not call this function to hide a scroll bar while processing a scroll-bar notification message.

If a call to SetScrollRange immediately follows a call to the SetScrollPos member function, set bRedraw in SetScrollPos to 0 to prevent the scroll bar from being redrawn twice.

The difference between the values specified by nMinPos and nMaxPos must not be greater than 32,767. The default range for a scroll-bar control is empty (both nMinPos and nMaxPos are 0).

Example

// Sets minimum (0) and maximum (10) position values for the
// CScrollBar control. m_ScrollBarVert is of type CScrollBar class, 
// and it is a member variable in CMyDialog class.
m_ScrollBarVert.SetScrollRange(0, 10);

// Set the position of the scroll box.
m_ScrollBarVert.SetScrollPos(5);

// Disable the down arrow of the scroll bar. By default, both arrows 
// are enabled.
m_ScrollBarVert.EnableScrollBar(ESB_DISABLE_DOWN);

Requirements

Header: afxwin.h

See Also

Concepts

CScrollBar Class

CScrollBar Members

Hierarchy Chart

CScrollBar::GetScrollPos

CScrollBar::SetScrollPos

CScrollBar::GetScrollRange

SetScrollRange