#include <Array.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $Row_a = 5, $Row_b = 5, $ButTxt1[33]
$Form1 = GUICreate("Form1", 200, 200, -1, -1)
$k = 1
For $i = 0 To $Row_a - 1
For $j = 0 To $Row_b - 1
$ButTxt1[$k] = GUICtrlCreateButton($k, 6 + 36 * $i, 6 + 36 * $j, 33, 33)
$k = $k + 1
Next
Next
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButTxt1[1]
Find1()
Case $ButTxt1[2]
Find2()
Case $ButTxt1[3]
Find3()
Case $ButTxt1[4]
Find4()
Case $ButTxt1[5]
Find5()
EndSwitch
WEnd
Func Find1()
$ShowNo = GUICtrlRead($ButTxt1[1])
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find1
Func Find2()
$ShowNo = GUICtrlRead($ButTxt1[2])
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find2
Func Find3()
$ShowNo = GUICtrlRead($ButTxt1[3])
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find3
Func Find4()
$ShowNo = GUICtrlRead($ButTxt1[4])
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find4
Func Find5()
$ShowNo = GUICtrlRead($ButTxt1[5])
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find5
点击某个按钮会显示该按钮上的值。
用循环。
[ 本帖最后由 qst 于 2009-3-17 17:10 编辑 ] |