Return index of item that has the focus rectangle
#Include <GuiList.au3>
_GUICtrlListGetCaretIndex($h_listbox)
Parameters
$h_listbox | control id/control hWnd |
Return Value
The return value is the zero-based index of the selected list box item.
Remarks
To determine the index of the item that has the focus rectangle in a
Related
_GUICtrlListGetTopIndex, _GUICtrlListGetAnchorIndex
Example
#include <GUIConstants.au3>
#include <GuiList.au3>
Opt ('MustDeclareVars', 1)
Dim $msg, $ret
Dim $listbox, $label, $button
GUICreate("ListBox Get Caret Index Demo", 400, 250, -1, -1)
$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Get Index", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetCaretIndex ($listbox)
GUICtrlSetData($label, "Item : " & $ret)
EndSelect
WEnd