MFC - Scrollbars



A scrollbar is a graphical control element with which continuous text, pictures or anything else can be scrolled in two directions along a control by clicking an arrow. This control can assume one of two directions horizontal or vertical. It is represented by CScrollBar class.

Here is the list of methods in CScrollBar class −

Sr.No. Name & Description
1

Create

Enables or disables one or both arrows of a scroll bar.

2

EnableScrollBar

Enables or disables one or both arrows of a scroll bar.

3

GetScrollBarInfo

Retrieves information about the scroll bar using a SCROLLBARINFO structure.

4

GetScrollInfo

Retrieves information about the scroll bar.

5

GetScrollLimit

Retrieves the limit of the scroll bar.

6

GetScrollPos

Retrieves the current position of a scroll box.

7

GetScrollRange

Retrieves the current minimum and maximum scroll-bar positions for the given scroll bar.

8

SetScrollInfo

Sets information about the scroll bar.

9

SetScrollPos

Sets the current position of a scroll box.

10

SetScrollRange

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

11

ShowScrollBar

Shows or hides a scroll bar.

Let us look into a simple example of Scrollbar.

Step 1 − To add either horizontal or vertical scrollbar, you need to set the following highlighted properties of the dialog box to True.

Scrollbar

Step 2 − When you run the above application, you will see that both horizontal and vertical scrollbars have been added.

Scrollbar
mfc_windows_controls.htm
Advertisements