#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $Button1
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 255, 132, 459, 264)
GUISetBkColor(0xA6CAF0)
$Button0 = GUICtrlCreateButton("Button0", 0, 0, 50, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 0, 50, 25)
GUISetState(@SW_SHOW)
_RegMsg($Form1, "Button_ClicK", "Button", 0, 2)
While 1
Sleep(100)
WEnd
Func Button_ClicK()
Switch @GUI_CtrlId
Case $Button0
MsgBox(0, 0, 2)
Case $Button1
MsgBox(0,0,1)
Case $Button2
_Child()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
EndFunc ;==>Button_ClicK
Func _Child()
$Form2 = GUICreate("Form2", 225, 97, 16, 25, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$Combo1 = GUICtrlCreateCombo("1", 48, 40, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "2|3|4|5", "1")
$Button1 = GUICtrlCreateButton("Button1", 80, 80, 75, 25)
GUICtrlSetOnEvent(-1,"Button_ClicK")
GUISetState(@SW_SHOW)
;~ _RegMsg($Form2, "Button_ClicK", "Button", 1, 1)
EndFunc ;==>_Child
;RegMsg(窗口句柄,函数名[,控件名,控件最小序号,控件最大序号])
Func _RegMsg($rHwnd, $rFunc, $rCtrl = Default, $rMin = Default, $rMax = Default)
GUISwitch($rHwnd)
If Opt("GUIEventOptions") Then
For $i = -13 To -4
GUISetOnEvent($i, $rFunc)
Next
EndIf
GUISetOnEvent(-3, $rFunc)
If Not IsKeyword($rCtrl) Then
If $rMin >= $rMax Then Return SetError(1, 0, 0)
For $i = $rMin To $rMax
GUICtrlSetOnEvent(Eval($rCtrl & $i), $rFunc)
Next
EndIf
Return SetError(0, 0, 1)
EndFunc ;==>_RegMsg
|