怎么用循环表达哪个按钮被点击?
#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
$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
Find1()
Case $ButTxt1
Find2()
Case $ButTxt1
Find3()
Case $ButTxt1
Find4()
Case $ButTxt1
Find5()
EndSwitch
WEnd
Func Find1()
$ShowNo = GUICtrlRead($ButTxt1)
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find1
Func Find2()
$ShowNo = GUICtrlRead($ButTxt1)
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find2
Func Find3()
$ShowNo = GUICtrlRead($ButTxt1)
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find3
Func Find4()
$ShowNo = GUICtrlRead($ButTxt1)
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find4
Func Find5()
$ShowNo = GUICtrlRead($ButTxt1)
MsgBox(0, "", $ShowNo)
EndFunc ;==>Find5
点击某个按钮会显示该按钮上的值。
用循环。
[ 本帖最后由 qst 于 2009-3-17 17:10 编辑 ]
Global $Row_a = 5, $Row_b = 5, $ButTxt1
$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 -3
Exit
Case $ButTxt1 To $ButTxt1
For $i = 1 To 25
If $nMsg = $ButTxt1[$i] Then MsgBox(0, 0, '你按下了:' & GUICtrlRead($ButTxt1[$i]) & '号按钮')
Next
EndSwitch
WEnd
学习了 case to
页:
[1]