| 1 | #include <GUIConstants.au3> |
|---|
| 2 | #include <GUIConstantsEx.au3> |
|---|
| 3 | #include <WindowsConstants.au3> |
|---|
| 4 | |
|---|
| 5 | Opt("GUIOnEventMode", 1) ; 1 = enable |
|---|
| 6 | Opt("GUIEventOptions", 0) ; 0 = (default) Windows behavior on click on Minimize,Restore, Maximize, Resize. |
|---|
| 7 | |
|---|
| 8 | $hGui = GUICreate("Test double event") |
|---|
| 9 | GUISetBkColor(0xABCDEF, $hGui) |
|---|
| 10 | |
|---|
| 11 | GUISetOnEvent($GUI_EVENT_CLOSE, "guiEventsHandler", $hGui) |
|---|
| 12 | GUISetOnEvent($GUI_EVENT_RESTORE, "guiEventsHandler", $hGui) |
|---|
| 13 | GUISetOnEvent($GUI_EVENT_MINIMIZE, "guiEventsHandler", $hGui) |
|---|
| 14 | |
|---|
| 15 | GuiCtrlCreateButton("Test input", 8, 8, 100, 30) |
|---|
| 16 | GUICtrlSetOnEvent(-1, buttonHandler) |
|---|
| 17 | |
|---|
| 18 | GuiCtrlCreateButton("Test input", 8, 46, 100, 30) |
|---|
| 19 | GUICtrlSetOnEvent(-1, buttonHandler2) |
|---|
| 20 | GUICtrlSetBkColor(-1, 0xABCDEF) |
|---|
| 21 | |
|---|
| 22 | GuiCtrlCreateInput("asdasd", 8, 84, 100, 30) |
|---|
| 23 | GUICtrlSetOnEvent(-1, inputHandler) |
|---|
| 24 | |
|---|
| 25 | GUISetState() |
|---|
| 26 | |
|---|
| 27 | While 1 |
|---|
| 28 | Sleep(10) |
|---|
| 29 | WEnd |
|---|
| 30 | |
|---|
| 31 | Func guiEventsHandler() |
|---|
| 32 | If @GUI_CtrlId == $GUI_EVENT_CLOSE Then Exit |
|---|
| 33 | If @GUI_CtrlId == $GUI_EVENT_RESTORE Then GUISetState(@SW_RESTORE, @GUI_WinHandle) |
|---|
| 34 | If @GUI_CtrlId == $GUI_EVENT_MAXIMIZE Then GUISetState(@SW_MAXIMIZE, @GUI_WinHandle) |
|---|
| 35 | If @GUI_CtrlId == $GUI_EVENT_MINIMIZE Then GUISetState(@SW_MINIMIZE, @GUI_WinHandle) |
|---|
| 36 | EndFunc |
|---|
| 37 | |
|---|
| 38 | Func buttonHandler() |
|---|
| 39 | MsgBox(0, "Button handler", "Got an event from the first button") |
|---|
| 40 | EndFunc |
|---|
| 41 | |
|---|
| 42 | Func buttonHandler2() |
|---|
| 43 | MsgBox(0, "Button handler", "Got an event from the second button") |
|---|
| 44 | EndFunc |
|---|
| 45 | |
|---|
| 46 | Func inputHandler() |
|---|
| 47 | MsgBox(0, "Input handler", "Got an event from the input") |
|---|
| 48 | EndFunc |
|---|