Ticket #2112: test3.au3

File test3.au3, 793 bytes (added by hebrayah@…, 13 years ago)

Script working correctly

Line 
1#include <GUIConstantsEx.au3>
2
3Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
4$mainwindow = GUICreate("Hello World", 200, 100)
5GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
6GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
7$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
8GUICtrlSetOnEvent($okbutton, "OKButton")
9GUISetState(@SW_SHOW)
10
11While 1
12  Sleep(1000)  ; Idle around
13WEnd
14
15Func OKButton()
16  ;Note: at this point @GUI_CTRLID would equal $okbutton,
17  ;and @GUI_WINHANDLE would equal $mainwindow
18  MsgBox(0, "GUI Event", "You pressed OK!")
19EndFunc
20
21Func CLOSEClicked()
22  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
23  ;and @GUI_WINHANDLE would equal $mainwindow
24  MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
25  Exit
26EndFunc