选择组合框编辑控件中的字符
#include <GuiComboBox.au3>
_GUICtrlComboBox_SetEditSel($hWnd, $iStart, $iStop)
$hWnd | 控件的控件ID/句柄 |
$iStart | 起始位置. |
$iStop | 结束位置 |
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
$Debug_CB = False ;检查传递给 ComboBox/ComboBoxEx 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
Global $iMemo
_Main()
Func _Main()
Local $aSel, $hCombo
; 创建 GUI
GUICreate("ComboBox Set Edit Sel", 400, 296)
$hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
$iMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
; 添加文件
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
_GUICtrlComboBox_EndUpdate($hCombo)
; Select Item
_GUICtrlComboBox_SetCurSel($hCombo, 2)
; Set Edit Sel
_GUICtrlComboBox_SetEditSel($hCombo, 0, 4)
; Get Edit Sel
$aSel = _GUICtrlComboBox_GetEditSel($hCombo)
MemoWrite(StringFormat("Edit Sel: %d - %d", $aSel[0], $aSel[1]))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
; 写入一行到 memo 控件
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite