Advertisement
Guest User

GuiCtrlSetOnEvent Example

a guest
Oct 27th, 2012
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.03 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. Opt ("GuiOnEventMode",1)
  5. $Form = GUICreate("GUI", 600, 450)
  6. $Button_P = GUICtrlCreateButton("Disable Buttons \/", 50, 30, 120, 25)
  7. Global $Button[6]
  8. For $i = 0 To 5
  9.     $Button[$i] = GUICtrlCreateButton("Button "&$i, 80, 65+$i*26 + 3, 75, 25)
  10.     GUICtrlSetOnEvent($Button[$i],"Controls")
  11. Next
  12.  
  13. GUISetOnEvent(-3,"EXIT_F")
  14. GUICtrlSetOnEvent($Button_P,"Controls")
  15. Global $DISABLE = False
  16. GUISetState(@SW_SHOW)
  17.  
  18. While 1
  19.  
  20. WEnd
  21.  
  22. Func EXIT_F()
  23.     Exit
  24. EndFunc
  25.  
  26. Func Controls()
  27.     Switch @GUI_CtrlId
  28.         Case $Button_P
  29.             Local $State = $GUI_DISABLE
  30.             If $DISABLE = True Then
  31.                 $State = $GUI_ENABLE
  32.                 $DISABLE = False
  33.                 GUICtrlSetData($Button_P,"Disable Buttons \/")
  34.             Else
  35.                 $DISABLE = True
  36.                 GUICtrlSetData($Button_P,"Enable Buttons \/")
  37.             EndIf
  38.             For $i = 0 To 5 Step 1
  39.                 GUICtrlSetState($Button[$i],$State)
  40.             Next
  41.         Case $Button[0] to $Button[5]
  42.             MsgBox(0,@GUI_CtrlId,GUICtrlRead(@GUI_CtrlId))
  43.     EndSwitch
  44. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement