我用绿色风的改了一下
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate('简单的多级联动,对应天气网ID', 570, 387, -1, -1)
Local $Button1 = GUICtrlCreateButton("显示", 5, 5, 75, 25)
$showLabel = GUICtrlCreateLabel('选择的区域', 85, 8, 300, 17)
GUISetState(@SW_SHOW)
Local $Form1_1 = GUICreate("", 560, 185, 2, 50, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_MDICHILD), $hGUI)
Local $List1 = GUICtrlCreateList("", 10, 30, 100, 136, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL, $WS_BORDER))
Local $List2 = GUICtrlCreateList("", 120, 30, 100, 136, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL, $WS_BORDER))
Local $List3 = GUICtrlCreateList("", 230, 30, 100, 136, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL, $WS_BORDER))
Local $List4 = GUICtrlCreateList("", 340, 30, 100, 136, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL, $WS_BORDER))
Local $List5 = GUICtrlCreateList("", 450, 30, 100, 136, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL, $WS_BORDER))
Local $Label1 = GUICtrlCreateLabel("省级", 10, 10, 99, 17)
Local $Label2 = GUICtrlCreateLabel("市级", 120, 10, 99, 17)
Local $Label3 = GUICtrlCreateLabel("县/区级", 230, 9, 99, 17)
Local $Label4 = GUICtrlCreateLabel("天气网的ID编号", 340, 10, 100, 17)
Local $Button2 = GUICtrlCreateButton("复位", 10, 160, 75, 25)
Local $Button3 = GUICtrlCreateButton("关闭", 90, 160, 75, 25)
#EndRegion ### END Koda GUI section ###
Dim $ini = "天气数据.dat"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($List2, "")
GUICtrlSetData($List3, "")
GUICtrlSetData($List4, "")
GUICtrlSetData($List5, "")
GUISetState(@SW_SHOW, $Form1_1)
GUICtrlSetData($List1, _ReadSection("省级")) ;省级目录
Case $Button2
GUICtrlSetData($List2, "")
GUICtrlSetData($List3, "")
GUICtrlSetData($List4, "")
GUICtrlSetData($List5, "")
GUICtrlSetData($List1, _ReadSection("省级")) ;省级目录
Case $Button3
GUISetState(@SW_HIDE, $Form1_1)
Case $List1 ;一级
GUICtrlSetData($List3, "")
GUICtrlSetData($List4, "")
GUICtrlSetData($List5, "")
Local $str = GUICtrlRead($List1)
GUICtrlSetData($List2, "")
GUICtrlSetData($List2, _ReadValue("省级", $str))
Case $List2 ;二级
GUICtrlSetData($List4, "")
GUICtrlSetData($List5, "")
Local $str = GUICtrlRead($List2) ;取地区
GUICtrlSetData($List3, _ReadSection($str)) ;省级目录
Case $List3 ;三级
GUICtrlSetData($List5, "")
Local $str0 = GUICtrlRead($List2);市级
Local $str1 = GUICtrlRead($List3) ;区县级
GUICtrlSetData($List4, "")
GUICtrlSetData($List4, _ReadValue($str0, $str1))
Case $List4 ;四级
Local $str = GUICtrlRead($List4)
GUICtrlSetData($List5, _ReadSection($str))
GUICtrlSetData($showLabel, GUICtrlRead($List1) & "→" & GUICtrlRead($List2) & "→" & GUICtrlRead($List3) & "→" & GUICtrlRead($List4))
Case $List5 ;五级
GUICtrlSetData($showLabel, GUICtrlRead($List1) & "→" & GUICtrlRead($List2) & "→" & GUICtrlRead($List3) & "→" & GUICtrlRead($List4) & "→" & GUICtrlRead($List5))
EndSwitch
WEnd
Func _ReadSection($field) ;字段的全部关键字
Local $str = ""
Local $arr = IniReadSection($ini, $field)
If Not @error Then
For $i = 1 To $arr[0][0]
$str = $str & "|" & $arr[$i][0]
Next
EndIf
Return $str
EndFunc ;==>_ReadSection
Func _ReadValue($field, $KEY)
Local $str2 = IniRead($ini, $field, $KEY, "")
Return $str2
EndFunc ;==>_ReadValue
|