返回列表中第一个可见项目的所在的索引
#include <GuiListBox.au3>
_GUICtrlListBox_GetTopIndex($hWnd)
$hWnd | 控件的控件ID/句柄 |
#include <GuiListBox.au3>
#include <GUIConstantsEx.au3>
$Debug_LB = False ;检查传递给 ListBox 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
_Main()
Func _Main()
Local $sText, $hListBox
; 创建 GUI
GUICreate("List Box Get Top Index", 400, 296)
$hListBox = GUICtrlCreateList("", 2, 2, 396, 296)
GUISetState()
; 添加字符串
_GUICtrlListBox_BeginUpdate($hListBox)
For $iI = 1 To 100
$sText = StringFormat("%03d : Random string ", $iI)
For $iX = 1 To Random(1, 20, 1)
$sText &= Chr(Random(65, 90, 1))
Next
_GUICtrlListBox_AddString($hListBox, $sText)
Next
_GUICtrlListBox_EndUpdate($hListBox)
; Show top index
MsgBox(4160, "信息", "Top Index: " & _GUICtrlListBox_GetTopIndex($hListBox))
; Set top index
_GUICtrlListBox_SetTopIndex($hListBox, 50)
; Show top index
MsgBox(4160, "信息", "Top Index: " & _GUICtrlListBox_GetTopIndex($hListBox))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main