#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
Global $Add_Button = 1000
Global $nMsg
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 464, 310, 318, 156)
$Button1 = GUICtrlCreateButton("确定", 45, 192, 169, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $Button1
$Form2 = GUICreate("Form2", 341, 148, 304, 293, -1, -1, $Form1)
$Button1_1 = GUICtrlCreateButton("给父窗口创建一个取消按钮", 80, 40, 169, 49)
GUISetState(@SW_SHOW)
While 1
$nMsg1 = GUIGetMsg(1)
If $nMsg1[1] = $Form2 Then
Switch $nMsg1[0]
Case $GUI_EVENT_CLOSE
Exit
Case $Button1_1
if Not IsHWnd($Add_Button) then $Add_Button = _GUICtrlButton_Create($Form1, "新增加的按钮", 45, 92, 169, 49)
$nMsg = GUIGetMsg()
GUIDelete($Form2)
ExitLoop
EndSwitch
EndIf
WEnd
EndSelect
WEnd
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
Local $hCtrl = $lParam
Local $sText = ""
Switch $hCtrl
Case $Add_Button
Switch $nNotifyCode
Case $BN_CLICKED
msgbox(0,0,"这是新增加的按钮")
EndSwitch
Return $GUI_RUNDEFMSG
EndSwitch
EndFunc ;==>WM_COMMAND
|