#include <GUIConstantsEx.au3>
Dim $x[5] = ["一", "二", "三", "四", "五"]
Dim $y[6] = ["11", "21", "31", "41", "51", "61"]
Dim $Button[5][6]
GUICreate("主窗口", 300, 300) ;创建主窗口
GUICtrlCreateTab(0, 0, 300, 300)
For $i1 = 0 To 4
GUICtrlCreateTabItem($x[$i1])
For $i2 = 0 To 5
$Button[$i1][$i2] = GUICtrlCreateButton($x[$i1] & $y[$i2], 20, 30 + 40 * $i2, 50, 30)
Next
Next
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
If $nMsg = $GUI_EVENT_CLOSE Then Exit
For $i1 = 0 To 4
For $i2 = 0 To 5
If $nMsg = $Button[$i1][$i2] Then
MyFun(String($i1) & String($i2))
ExitLoop
EndIf
Next
Next
WEnd
Func MyFun($btnIndex)
Switch $btnIndex
Case "00"
MsgBox(0, "", "你按了 一11 按钮")
Case "01"
MsgBox(0, "", "你按了 一21 按钮")
Case "02"
MsgBox(0, "", "你按了 一31 按钮")
EndSwitch
EndFunc ;==>MyFun
|