试试这样
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiEdit.au3>;
$Debug_CB = False ; 檢查傳遞到 ComboBox / ComboBoxEx 函數的控制項類名, 設置為 True, 並使用一個控制碼到另一個控制項, 查看它的工作
Global $hCombo
_Main()
Func _Main()
Local $hGUI
; 創建 GUI
$hGUI = GUICreate("創建 ComboBox 控制項", 400, 296)
$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296)
GUISetState()
; 添加文件
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddDir($hCombo, "", $DDL_DRIVES, False)
_GUICtrlComboBox_EndUpdate($hCombo)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
; 迴圈到用戶退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode ,$sText
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; 低位字
$iCode = BitShift($iwParam, 16) ; 高位字
Switch $hWndFrom
Case $hCombo
Switch $iCode
Case $CBN_SELCHANGE ; 發送使用者修改下拉式列示方塊的清單方塊的當前選擇消息
_DebugPrint("$CBN_SELCHANGE" & @LF & "--> 控制項控制碼:" & @TAB & $hWndFrom & @LF & _
"--> 控制項 ID:" & @TAB & $iIDFrom & @LF & _
"--> 操作代碼:" & @TAB & $iCode)
; 沒有返回值
_GUICtrlComboBox_GetLBText($hCombo, _GUICtrlComboBox_GetCurSel($hCombo), $sText)
;~ ConsoleWrite("A......................." & _GUICtrlComboBox_GetEditText($hCombo) & @CRLF)
ConsoleWrite("A......................." & $sText & @CRLF)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"--> 行(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint
|