home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 February / PCWorld_2006-02_cd.bin / software / vyzkuste / triky / triky.exe / autoit-v3-setup.exe / Examples / GUISetOnEvent.au3 < prev    next >
Text File  |  2005-01-07  |  1KB  |  58 lines

  1. #include <GUIConstants.au3>
  2.  
  3. Opt("GUICoordMode",2)
  4. Opt("GUIResizeMode", 1)
  5. Opt("GUIOnEventMode", 1)
  6.  
  7. $parent1 = GUICreate("Parent1")
  8. GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
  9. GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
  10. GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
  11.  
  12.  
  13. $ok1 = GUICtrlCreateButton ("OK",  10, 30, 50)
  14. GUICtrlSetOnEvent(-1, "OKPressed")
  15.  
  16. $cancel1 = GUICtrlCreateButton ( "Cancel",  0, -1)
  17. GUICtrlSetOnEvent(-1, "CancelPressed")
  18.  
  19. GUISetState(@SW_SHOW)
  20.  
  21.  
  22. ; Just idle around
  23. While 1
  24.     Sleep(10)
  25. Wend
  26.  
  27.  
  28. ; END
  29.  
  30.  
  31. Func OKPressed()
  32.     MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
  33. EndFunc
  34.  
  35.  
  36. Func CancelPressed()
  37.     MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
  38. EndFunc
  39.  
  40.  
  41. Func SpecialEvents()
  42.     
  43.  
  44.     Select
  45.         Case @GUI_CTRLID = $GUI_EVENT_CLOSE
  46.             MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
  47.             Exit
  48.             
  49.         Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
  50.             MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
  51.             
  52.         Case @GUI_CTRLID = $GUI_EVENT_RESTORE
  53.             MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
  54.             
  55.     EndSelect
  56.     
  57. EndFunc
  58.