Changes the state of a control.
GUICtrlSetState ( controlID, state )
| controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control. |
| state | See the State table below. |
| Success: | 1. |
| Failure: | 0. |
| State | Comments |
|---|---|
| $GUI_CHECKED (1) | Radio, Checkbox, MenuItem or ListViewItem will be checked. |
| $GUI_INDETERMINATE (2) | Checkbox having the tristate attribute will be greyed. |
| $GUI_UNCHECKED (4) | Radio, Checkbox, MenuItem or ListViewItem will be unchecked. |
| $GUI_DROPACCEPTED (8) | Control will accept drop action : from file or from a drag of another control. See remarks. |
| $GUI_SHOW (16) | Control will be visible. On Tabitem control will select the first tab to be displayed. |
| $GUI_HIDE (32) | Control will not be visible. |
| $GUI_ENABLE (64) | Control will be enabled. |
| $GUI_DISABLE (128) | Control will be greyed out. |
| $GUI_FOCUS (256) | Control will be given input/selected focus. |
| $GUI_DEFBUTTON (512) | Control will be set as the default button on the window. See remark about TreeviewItems. |
| $GUI_EXPAND (1024) | TreeViewItem will expand its child items. |
| $GUI_ONTOP (2048) | Control will be have the ontop attribute for the window (zOrdering). |
| $GUI_NODROPACCEPTED (4096) | Control will not accept drop action. |
| $GUI_NOFOCUS (8192) | Listview control will loose focus. |
| $GUI_AVISTART (0) | Avi control will start playing. |
| $GUI_AVISTOP (1) | Avi control will stop playing. |
| $GUI_AVICLOSE (2) | Avi control will stop playing and release resource. |
GUICtrlCreate..., GUICtrlGetState
#include <GUIConstantsEx.au3>
#include <WindowsStylesConstants.au3>
Example()
Func Example()
; Create a GUI with various controls.
Local $hGUI = GUICreate("Example", 420, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)
; Create a label and set the state as drop accepted.
Local $idLabel = GUICtrlCreateLabel("Drop a file on this label.", 10, 10, 400, 40, $WS_BORDER)
GUICtrlSetState($idLabel, $GUI_DROPACCEPTED)
; Create an input and set the state as drop accepted.
Local $idInput = GUICtrlCreateInput("", 10, 60, 400, 22)
GUICtrlSetState($idInput, $GUI_DROPACCEPTED)
Local $idButton_OK = GUICtrlCreateButton("OK", 310, 170, 85, 25)
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idButton_OK
ExitLoop
Case $GUI_EVENT_DROPPED
; If the value of @GUI_DropId is $idLabel, then set the label of the dragged file.
If @GUI_DropId = $idLabel Then GUICtrlSetData($idLabel, @GUI_DragFile)
EndSwitch
WEnd
; Delete the previous GUI and all controls.
GUIDelete($hGUI)
EndFunc ;==>Example