If Not FileExists('config.ini') Then
For $i = 1 To 155
IniWrite('config.ini', 'tip' & $i, 'name', '可点击的Label' & $i)
IniWrite('config.ini', 'tip' & $i, 'ip', '127.0.0.' & $i)
Next
Msgbox(0, 0, 'config.ini 创建完毕~ ')
EndIf
;--------------以上会生成测试用的ini文件,以下脚本正式开始。
#include <ComboConstants.au3>
$ini = 'config.ini'
GUICreate('根据ini生成控件例子', 260, 120)
GUICtrlCreateLabel('请下拉选择项目:', 20, 24, 100, 17)
$Combo = GUICtrlCreateCombo("", 120, 20, 120, 20, BitOr($GUI_SS_DEFAULT_COMBO,0x0800,0x0003))
$Label = GUICtrlCreateLabel('', 20, 50, 120, 17)
GUICtrlSetColor(-1, 0x06366c)
GUICtrlSetFont(-1, 9, 800, 0)
GUICtrlSetCursor(-1, 0)
GUISetState()
$iniRSN = IniReadSectionNames($ini)
Dim $tmp, $ip = '还未选择'
For $i = 1 To $iniRSN[0] - 1
$tmp &= $iniRSN[$i] & '|'
Next
$tmp &= $iniRSN[$i]
GUICtrlSetData($Combo, $tmp)
GUIRegisterMsg(0x0111, "WM_COMMAND")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Label
MsgBox(0, 0, $ip)
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $IdFrom, $iCode, $zdm, $name
$IdFrom = BitAND($wParam, 0x0000FFFF)
$iCode = BitShift($wParam, 16)
If $iCode = 1 Then
If $IdFrom = $Combo Then
$zdm = GUICtrlRead($Combo)
$name = IniRead($ini, $zdm, 'name', '')
GUICtrlSetData($Label, $name)
$ip = IniRead($ini, $zdm, 'ip', '')
EndIf
EndIf
EndFunc ;==>WM_COMMAND