Export (0) Print
Expand All
3 out of 15 rated this helpful - Rate this topic

Scroll Bar

This section contains information about the programming elements used with scroll bars. A window can display a data object, such as a document or a bitmap, that is larger than the window's client area. When provided with a scroll bar, the user can scroll a data object in the client area to bring into view the portions of the object that extend beyond the borders of the window.

Overviews

TopicContents
About Scroll Bars

A scroll bar consists of a shaded shaft with an arrow button at each end and a scroll box (sometimes called a thumb) between the arrow buttons.

Using Scroll Bars

When creating an overlapped, pop-up, or child window, you can add standard scroll bars by using the CreateWindowEx function and specifying WS_HSCROLL, WS_VSCROLL, or both styles.

 

Functions

TopicContents
EnableScrollBar

The EnableScrollBar function enables or disables one or both scroll bar arrows.

GetScrollBarInfo

The GetScrollBarInfo function retrieves information about the specified scroll bar.

GetScrollInfo

The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb).

GetScrollPos

The GetScrollPos function retrieves the current position of the scroll box (thumb) in the specified scroll bar. The current position is a relative value that depends on the current scrolling range. For example, if the scrolling range is 0 through 100 and the scroll box is in the middle of the bar, the current position is 50.

Note   The GetScrollPos function is provided for backward compatibility. New applications should use the GetScrollInfo function.

GetScrollRange

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.

ScrollDC

The ScrollDC function scrolls a rectangle of bits horizontally and vertically.

ScrollWindow

The ScrollWindow function scrolls the contents of the specified window's client area.

Note  The ScrollWindow function is provided for backward compatibility. New applications should use the ScrollWindowEx function.

ScrollWindowEx

The ScrollWindowEx function scrolls the contents of the specified window's client area.

SetScrollInfo

The SetScrollInfo function sets the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb). The function also redraws the scroll bar, if requested.

SetScrollPos

The SetScrollPos function sets the position of the scroll box (thumb) in the specified scroll bar and, if requested, redraws the scroll bar to reflect the new position of the scroll box.

Note  The SetScrollPos function is provided for backward compatibility. New applications should use the SetScrollInfo function.

SetScrollRange

The SetScrollRange function sets the minimum and maximum scroll box positions for the specified scroll bar.

Note  The SetScrollRange function is provided for backward compatibility. New applications should use the SetScrollInfo function.

ShowScrollBar

The ShowScrollBar function shows or hides the specified scroll bar.

 

Messages

TopicContents
SBM_ENABLE_ARROWS

An application sends the SBM_ENABLE_ARROWS message to enable or disable one or both arrows of a scroll bar control.

SBM_GETPOS

The SBM_GETPOS message is sent to retrieve the current position of the scroll box of a scroll bar control. The current position is a relative value that depends on the current scrolling range. For example, if the scrolling range is 0 through 100 and the scroll box is in the middle of the bar, the current position is 50.

Applications should not send this message directly. Instead, they should use the GetScrollPos function. A window receives this message through its WindowProc function. Applications which implement a custom scroll bar control must respond to these messages for the GetScrollPos function to function properly.

SBM_GETRANGE

The SBM_GETRANGE message is sent to retrieve the minimum and maximum position values for the scroll bar control.

Applications should not send this message directly. Instead, they should use the GetScrollRange function. A window receives this message through its WindowProc function. Applications which implement a custom scroll bar control must respond to these messages for the GetScrollRange function to work properly.

SBM_GETSCROLLBARINFO

Sent by an application to retrieve information about the specified scroll bar.

SBM_GETSCROLLINFO

The SBM_GETSCROLLINFO message is sent to retrieve the parameters of a scroll bar.

Applications should not send this message directly. Instead, they should use the GetScrollInfo function. A window receives this message through its WindowProc function. Applications which implement a custom scroll bar control must respond to these messages for the GetScrollInfo function to work properly.

SBM_SETPOS

The SBM_SETPOS message is sent to set the position of the scroll box (thumb) and, if requested, redraw the scroll bar to reflect the new position of the scroll box.

Applications should not send this message directly. Instead, they should use the SetScrollPos function. A window receives this message through its WindowProc function. Applications which implement a custom scroll bar control must respond to these messages for the SetScrollPos function to work properly.

SBM_SETRANGE

The SBM_SETRANGE message is sent to set the minimum and maximum position values for the scroll bar control.

Applications should not send this message directly. Instead, they should use the SetScrollRange function. A window receives this message through its WindowProc function. Applications which implement a custom scroll bar control must respond to these messages for the SetScrollRange function to work properly.

SBM_SETRANGEREDRAW

An application sends the SBM_SETRANGEREDRAW message to a scroll bar control to set the minimum and maximum position values and to redraw the control.

SBM_SETSCROLLINFO

The SBM_SETSCROLLINFO message is sent to set the parameters of a scroll bar.

Applications should not send this message directly. Instead, they should use the SetScrollInfo function. A window receives this message through its WindowProc function. Applications which implement a custom scroll bar control must respond to these messages for the SetScrollInfo function to function properly.

 

Notifications

TopicContents
WM_CTLCOLORSCROLLBAR

The WM_CTLCOLORSCROLLBAR message is sent to the parent window of a scroll bar control when the control is about to be drawn. By responding to this message, the parent window can use the display context handle to set the background color of the scroll bar control.

A window receives this message through its WindowProc function.

WM_HSCROLL

The WM_HSCROLL message is sent to a window when a scroll event occurs in the window's standard horizontal scroll bar. This message is also sent to the owner of a horizontal scroll bar control when a scroll event occurs in the control.

A window receives this message through its WindowProc function.

WM_VSCROLL

The WM_VSCROLL message is sent to a window when a scroll event occurs in the window's standard vertical scroll bar. This message is also sent to the owner of a vertical scroll bar control when a scroll event occurs in the control.

A window receives this message through its WindowProc function.

 

Structures

TopicContents
SCROLLBARINFO

The SCROLLBARINFO structure contains scroll bar information.

SCROLLINFO

The SCROLLINFO structure contains scroll bar parameters to be set by the SetScrollInfo function (or SBM_SETSCROLLINFO message), or retrieved by the GetScrollInfo function (or SBM_GETSCROLLINFO message).

 

Constants

TopicContents
Scroll Bar Control Styles

To create a scroll bar control using the CreateWindow or CreateWindowEx function specify the SCROLLBAR class, appropriate window style constants, and a combination of the following scroll bar control styles. Some of the styles create a scroll bar control that uses a default width or height. However, you must always specify the x- and y-coordinates and the other dimensions of the scroll bar when you call CreateWindow or CreateWindowEx.

 

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.