Function Reference

_GUICtrlListGetTopIndex

Retrieve the index of the first visible item in a list

#Include <GuiList.au3>
_GUICtrlListGetTopIndex($h_listbox)

 

Parameters

$h_listbox control id/control hWnd

 

Return Value

The return value is the index of the first visible item in the list box.
If the list is empty then $LB_ERR is returned.

 

Remarks

Initially the item with index 0 is at the top of the list box, but if
the list box contents have been scrolled another item may be at the top.
Returns index of the first visible item in the list box
useful since contents for a long list will scroll

 

Related

_GUICtrlListSetTopIndex

 

Example


#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $label, $i

GUICreate("ListBox Get Top Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|")
$button = GUICtrlCreateButton("Get Top Index", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Top Index:", 150, 210, 120)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            $ret = _GUICtrlListGetTopIndex ($listbox)
            If ($ret == $LB_ERR) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetTopIndex")
            Else
                GUICtrlSetData($label, "Top Index: " & $ret)
            EndIf
    EndSelect
WEnd