函数参考


GUICtrlSetState

调整指定控件的状态.

GUICtrlSetState ( 控件ID, 状态 )

参数

控件ID 控件标识符(控件ID),可由 GUICtrlCreate... 函数的返回值获得.
状态 请查看下面的 状态表.

返回值

成功: 返回值为1.
失败: 返回值为0.

注意/说明


    状态表


状态列表 详细信息
无变化 0
$GUI_UNCHECKED 单选按框钮(Radio)或复选框按钮(Checkbox)将被取消选中
$GUI_CHECKED 单选按框钮(Radio)或复选框按钮(Checkbox)将被选中
$GUI_INDETERMINATE 具有三态属性的复选框(Checkbox)将变成灰色(不可用)状态
$GUI_AVISTART Avi 控件开始播放
$GUI_AVISTOP Avi 控件停止播放
$GUI_AVICLOSE Avi 控件停止播放并释放资源.
$GUI_DROPACCEPTED 控件可以接受拖放操作的放下操作: 从一个文件或者其它控件.参考注意项目.
$GUI_NODROPACCEPTED 控件不能接受拖放操作的放下操作.
$GUI_SHOW 控件将可见.对于标签项则第一个标签页将被显示
$GUI_HIDE 控件将不可见.
$GUI_ENABLE 控件将可用.
$GUI_DISABLE 控件将变成灰色状态(不可用)
$GUI_FOCUS 控件将会得到输入/选择焦点.
$GUI_NOFOCUS Listview 控件将会失去焦点.
$GUI_DEFBUTTON 控件将会被设置为窗口的默认按钮. 参考关于 TreeviewItems 的备注.
$GUI_EXPAND TreeViewItem 将会展开它的子项目.
$GUI_ONTOP 控件将会拥有一个相对于窗口的置顶属性(Z轴).

状态值可以加起来使用,比如像下面示例中的 $GUI_DISABLE + $GUI_HIDE 将使控件变为禁用并且隐藏状态.

若要隐藏某个 AVI 控件(使用 $GUI_HIDE),应该使用 $GUI_AVICLOSE 来关闭它.

"上下文菜单" 控件的状态 不能被修改.
State of a "listviewitem" control can be changed if the associated "listview" control has been created with an extended style $LVS_EX_CHECKBOXES. $GUI_FOCUS and $GUI_NOFOCUS can be used on specific listviewitem provided listview control style allows to display it : $LVS_SHOWSELALWAYS.
State of a "menu or a ""menuitem" control cannot be hidden.

! Important information for $GUI_EXPAND: this state is only used for TreeViewItems. If you want to use this 'action' then at least 1 Sub-TreeViewItem has to exist/created under this item !
If you want to select another item in a TreeView then you can use $GUI_FOCUS - the parent TreeView gets the window focus and the specified item is marked as selected.
If you want to set a treeview item as a default item which means painting it bold you can use $GUI_DEFBUTTON - to turn it off just use another value but $GUI_DEFBUTTON, for instance 0. This state will not be returned by GUICtrlGetState.

If $GUI_DROPACCEPTED is set to a visible control a drag&drop can be taken in account. The edit/input control will be set with the filename.
For other controls on reception of $GUI_EVENT_DROPPED, @GUI_DRAGID will return the controlID from where the drag start (-1 if from a file, @GUI_DRAGFILE contain the filename being dropped) and @GUI_DROPID returns the controlID of the dropped control.
Only dragging a ListviewItem will start the drag & drop process. The @GUI_DRAGID will be the ListView controlID.

相关

GUICtrlCreate..., GUICtrlGetState

示例/演示


#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg

    GUICreate("My GUI state") ; will create a dialog box that when displayed is centered

    GUICtrlCreateLabel("my disable label", 10, 20)
    GUICtrlSetState(-1, $GUI_DISABLE) ; the label is in disable state

    GUICtrlCreateButton("my button", 50, 50)
    GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example