这个很好玩哈,关键是新增加的按钮如何响应事件.
;GUItest
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $Button[100]
Global $N=0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("华仔最帅!!", 1, 1, 193, 125, $WS_CLIPCHILDREN)
;~ $Pic1 = GUICtrlCreatePic("D:\桌面\1920DOG_1009.jpg", -1, -1, 581, 443)
GUISetState(@SW_SHOW)
For $i = 1 To 581 Step 1
WinMove('华仔最帅!!', '', 100, 100, $i, $i - 138)
Next
#EndRegion ### END Koda GUI section ###
$Button1 = GUICtrlCreateButton("动态添加一个按钮", 8, 40, 120, 25)
$Button3 = GUICtrlCreateButton("删除新建", 20, 100, 89, 25)
ControlHide('', '', $Button3)
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg=$GUI_EVENT_CLOSE
Exit
Case $nMsg=$Button1
$Button[$N] = GUICtrlCreateButton("我是新按钮"&$N+1, 150, $N*40+40, 89, 25)
$N+=1
ControlShow('', '', $Button3)
Case $nMsg=$Button3
if $N-1>0 Then
GUICtrlDelete($Button[$N-1])
$Button[$N-1]=""
$N-=1
Else
$N-=1
GUICtrlDelete($Button[$N])
$Button[$N]=""
ControlHide('', '', $Button3)
EndIf
Case $nMsg>$Button3
msgbox(0,0,"新按钮"&$nMsg-$Button3)
EndSelect
WEnd
|