获取组合框的列表部分中第一个可见项从0开始的索引
#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetTopIndex($hWnd)
$hWnd | 控件句柄 |
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
$Debug_CB = False ;检查传递给 ComboBox/ComboBoxEx 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
_Main()
Func _Main()
Local $hGUI, $hCombo
; 创建 GUI
$hGUI = GUICreate("ComboBoxEx Get Top Index", 400, 300)
$hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
GUISetState()
_GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
_GUICtrlComboBoxEx_BeginUpdate($hCombo)
For $x = 0 To 149
_GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
Next
_GUICtrlComboBoxEx_EndUpdate($hCombo)
;Set Top Index
MsgBox(4160, "信息", "Set Top Index: " & _GUICtrlComboBoxEx_SetTopIndex($hCombo, Random(50, 149, 1)))
MsgBox(4160, "信息", "Top Index: " & _GUICtrlComboBoxEx_GetTopIndex($hCombo))
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main