CScrollBar

Win32++

CScrollBar Class

Description

The CScrollBar class is used to create and manage a scroll bar control. Scroll bars are used when the window isn't large enough to display all of its content, such as a bitmap or a document. Scroll bars can be used to bring into view the portions of the content that extend beyond the borders of the window.

Refer to the documentation that ships with the Microsoft Windows Software Development Kit for more information on the use of scroll bar controls.

CScrollBar Members

CScrollBar
CScrollBar();
Constructor for the CScrollBar.
EnableScrollbar
BOOL EnableScrollBar( UINT nArrowFlags = ESB_ENABLE_BOTH ) const;
Enables or disables one or both scroll bar arrows. GetScrollInfo
BOOL GetScrollInfo(LPSCROLLINFO lpsi) const;
Retrieves information that the SCROLLINFO structure maintains about the scroll bar. GetScrollPos
int GetScrollPos() const;
Retrieves the current position of the scroll box. GetScrollRange
BOOL GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos ) const;
Retrieves the current minimum and maximum scroll box positions. SetScrollInfo
BOOL SetScrollInfo(LPSCROLLINFO lpsi, BOOL bRedraw = TRUE ) const;
Sets the information that the SCROLLINFO structure maintains about the scroll bar. SetScrollPos
int SetScrollPos(int nPos, BOOL bRedraw) const;
Sets the position of the scroll box and, if requested, refraws the scroll bar to reflect the new position of the scroll box. SetScrollRange
BOOL SetScrollRange( int nMinPos, int nMaxPos, BOOL bRedraw = TRUE ) const;
Sets the minimum and maximum scroll box positions for the scroll bar. ShowScrollBar
BOOL ShowScrollBar(BOOL bShow) const;
Shows or hides the scroll bar.

Overridables

PreRegisterClass
virtual void PreRegisterClass(WNDCLASS &wc);
Set the window class parameters before the window is created.
Base class Members

For base class members, refer to the members of CWnd.

Remarks

Like all common controls, the scroll bar control requires a parent window. This parent window is often a dialog, but simple windows can also be the parent window for a scroll bar control.

There are two ways to add scroll bars to a window.

  • Create the window with the WS_HSCROLL and/or WS_VSCROLL styles.
  • Create a horizontal and/or vertical scroll bar control as a child window we wish to scroll.

Use the SBS_HORZ style to create a horizontal scroll bar control, and the SBS_VERT style to create a vertical scroll bar control.

Summary Information

Header file controls.h
Win32/64 support Yes
WinCE support Yes