ScrollBars Property

Purpose

Returns or sets a value indicating whether an object has horizontal or vertical scroll bars.

Syntax

object.ScrollBars [ = value ]

object:Form, TextBox object
value:iexp

Description

The following values are allowed:

basNoScroll (0) (Default) None
basHorizontal (1) Horizontal
basVertical (2) Vertical
basBoth (3) Both scrollbars

For a TextBox control with setting 1 (Horizontal), 2 (Vertical), or 3 (Both), you must set the MultiLine property to True.

Example

OpenW 1

Ocx CheckBox chk(0) = "Show Horizontal Scroll Bar", 10, 10, 200, 14

Ocx CheckBox chk(1) = "Show Vertical Scroll Bar", 10, 30, 200, 14

Do : Sleep : Until Win_1 Is Nothing

 

Sub chk_Click(Index%)

If chk(Index%).Value = 0

Win_1.ScrollBars = Bclr(Win_1.ScrollBars, Index%)

Else

Win_1.ScrollBars = Bset(Win_1.ScrollBars, Index%)

EndIf

EndSub

Remarks

The scrollbar minimum, maximum, step size, and current position can be set with HSc* and VSc* properties.

The scrolling events are handled with HScroll, HScrolling, VScroll, and VScrolling event subs.

Known Issue

If you wish the scroll bar(s) to be visible only when your work area grows bigger than the window area, toggling the ScrollBar property between 0, 1, 2 and 3 has been known to cause a fatal error. Instead, it is advised to use the HScMax and VScMax properties to achieve the same end as setting these properties to zero causes the respective scroll bar to disappear. It is also possible to use the EnableScrollBar() API to disable the scroll bars but keep them visible. The example below illustrates how this works:

OpenW 1 : Win_1.ScrollBars = 3 : Win_1.BackColor = $8000000f

Ocx Option opt(1) = "Enable Horizontal Scrollbar", 10, 10, 200, 15 : opt(1).Value = 1

Ocx Option opt(2) = "Disable Horizontal Scrollbar", 10, 25, 200, 15

Ocx Command cmd // Breaks option groups

Ocx Option opt(3) = "Show Horizontal Scrollbar", 10, 50, 200, 15 : opt(3).Value = 1

Ocx Option opt(4) = "Hide Horizontal Scrollbar", 10, 65, 200, 15

Do : Sleep : Until Win_1 Is Nothing

 

Sub opt_Click(Index%)

Select Index%

Case 1 : ~EnableScrollBar(Win_1.hWnd, SB_HORZ, ESB_ENABLE_BOTH)

Case 2 : ~EnableScrollBar(Win_1.hWnd, SB_HORZ, ESB_DISABLE_BOTH)

Case 3 : Win_1.HScMax = 1000

Case 4 : Win_1.HScMax = 0

EndSelect

EndSub

The same can be done for the vertical scroll bar by substituting SB_VERT and VScMax for SB_HORZ and HScMax respectively.

See Also

Form, TextBox, HScroll, HScrolling, VScroll, VScrolling, VScMax, VScMin, VScPos, VScPage, VScStep, VScTrack, HScMax, HScMin, HScPos, HScPage, HScStep, HScTrack

{Created by Sjouke Hamstra; Last updated: 02/07/2015 by James Gaite}