ScrollBar

Scroll Bar control.

Summary
ScrollBarScroll Bar control.
AddCreates scroll bar control.
GetGet the scrollbar parameter.
SetSet scroll bar parameters.
SetPosSet scroll bar position and redraws it.
EnableEnable or disable scroll bar.
ShowShow or hide scroll bar.
Example
About

Add

ScrollBar_Add(HParent,  
X,  
Y,  
W = "",
H = "",
Handler = "",
o1 = "",
o2 = "",
o3 = "",
o4 = "",
o5 = "")

Creates scroll bar control.

Parameters

HParentHandle of the parent window.
X..HPosition.  You can omit width and height to use system’s default for vertical or horizontal scroll bar.  To glue scroll bar to another GUI control, specify control’s handle as X parameter and omit Y parameter.  In glue mode, y parameter is ignored; w is ignored for horizontal, and h for vertical scroll bar.
HandlerHandler routine.  See below.
o1..o5Optional parameters.

Named parameters

style”hor” (defualt) or “ver”.
min, maxrange, by default 0, 100.
posinitial position of the slider, by deafult 0.
pagepage, by default 10.

Handler

Handler(HCtrl, Pos)
HCtrlHandle of the control sending notification.
PosPosition of the slider.

Returns

Handle of the control, error message if control can not be created.

Example

hHBar := ScrollBar_Add(hwnd, 0, 0, 280, -1, “OnScroll”, “style=ver”, “min=1”, “max=100”, “page=10”, “pos=10”) ScrollBar_Add(hwnd, “myEdit”, 0, 0, 0, “OnScroll”) ;glue to the myEdit GUI control

Get

ScrollBar_Get( HCtrl,  
 pQ = "",
ByRef o1 = "",
ByRef o2 = "",
ByRef o3 = "",
ByRef o4 = "",
ByRef o5 = "")

Get the scrollbar parameter.

Parameters

HCtrlHandle of the scroll bar control.
pQQuery parameter.  Any space separated combination of pos, page, min, max, track.  Omit to return all data in that order.
o1..o5Reference to oputut variables.

Returns

o1 on success, nothing on failure.

Set

ScrollBar_Set(HCtrl,  
Pos = "",
Min = "",
Max = "",
Page = "",
Redraw = "")

Set scroll bar parameters.

Parameters

HCtrlHandle of the scroll bar control.
PosSet position, by default 0.
PageSet page, optional.
MinSet minimum, optional.
MaxSet maximum, optional.
RedrawSet to true to redraw the scroll bar.

Returns

Current position of the scroll bar.

SetPos

ScrollBar_SetPos(HCtrl,  
Pos = 1)

Set scroll bar position and redraws it.

Parameters

HCtrlHandle to the scroll bar control.
PosPosition to set (default = 1).

Returns

Previous position.

Enable

ScrollBar_Enable(HCtrl,  
Enable = true)

Enable or disable scroll bar.

Parameters

HCtrlHandle to the scroll bar control.
EnableTrue to enable, false to desable (default=true).

Show

ScrollBar_Show(HCtrl,  
Show = true)

Show or hide scroll bar.

Parameters

HCtrlHandle to the scroll bar control.
ShowTrue to show, false to hide (default=show).

Returns

Positive number on success, 0 on failure.

Example

    Gui,  +LastFound
    hGui := WinExist()

    Gui, Add, Edit, -vscroll y50 h100 w230 vMyEdit, 0
    hHBar := ScrollBar_Add(hGui, 0,   10, 280, 8,  "OnScroll", "min=0", "max=50", "page=5")
    hVBar := ScrollBar_Add(hGui, 280, 10, -1,  290, "OnScroll", "style=ver", "pos=10")

    ;glue to the MyEdit
    hhE := ScrollBar_Add(hGui, "myEdit", 0, 0, 10, "OnScroll", "pos=50")
    hvE := ScrollBar_Add(hGui, "myEdit", 0, 0, 0, "OnScroll", "style=ver", "pos=50")

    Gui, show, h300 w300, ScrollBar Test
return

OnScroll:
    if (ScrollBar_HWND = hHBar)
         s := "horizontal"
    else if (ScrollBar_HWND = hVBar)
         s := "vertical"
    else s := "glued"

    ControlSetText, Edit1, %ScrollBar_POS% - %s% bar
return

About

ScrollBar_Add(HParent,  
X,  
Y,  
W = "",
H = "",
Handler = "",
o1 = "",
o2 = "",
o3 = "",
o4 = "",
o5 = "")
Creates scroll bar control.
ScrollBar_Get( HCtrl,  
 pQ = "",
ByRef o1 = "",
ByRef o2 = "",
ByRef o3 = "",
ByRef o4 = "",
ByRef o5 = "")
Get the scrollbar parameter.
ScrollBar_Set(HCtrl,  
Pos = "",
Min = "",
Max = "",
Page = "",
Redraw = "")
Set scroll bar parameters.
ScrollBar_SetPos(HCtrl,  
Pos = 1)
Set scroll bar position and redraws it.
ScrollBar_Enable(HCtrl,  
Enable = true)
Enable or disable scroll bar.
ScrollBar_Show(HCtrl,  
Show = true)
Show or hide scroll bar.
Close