使此后所有被創(chuàng)建的控件都?xì)w為一組。
GUIStartGroup ( [窗口句柄] )
參數(shù)
| 窗口句柄 | [可選參數(shù)] 窗口句柄,可由 GUICreate 的返回值獲得(若缺省則使用上一次用過的句柄)。 |
返回值
| 成功: | 返回值為1。 |
| 失。 | 返回值為0。 |
注意
本函數(shù)一般用于單選按鈕控件。當(dāng)用戶點(diǎn)擊某個(gè)單選按鈕時(shí)其它所有在同一組的單選按鈕將被重設(shè)。GUIStartGroup 函數(shù)使得我們能夠輕松地定義控件組。
相關(guān)
GUICtrlCreateGroup
示例
#include <GUIconstants.au3>
Opt("GUICoordMode", 1)
GUICreate("單選按鈕歸組演示", 400,280)
; 創(chuàng)建控件
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)
$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)
GUIStartGroup()
$radio_4 = GUICtrlCreateRadio ("Radio &A", 120, 120, 70, 20)
$radio_5 = GUICtrlCreateRadio ("Radio &B", 120, 150, 60, 20)
$radio_6 = GUICtrlCreateRadio ("Radio &C", 120, 180, 60, 20)
GUIStartGroup()
$input_1 = GUICtrlCreateInput ("Input 1", 200, 20, 160, 30)
$input_2 = GUICtrlCreateInput ("Input 2", 200, 70, 160, 30)
; 設(shè)置默認(rèn)項(xiàng)目(定義默認(rèn)選中的單選按鈕、默認(rèn)按鈕,等等)
GUICtrlSetState($radio_1, $GUI_CHECKED)
GUICtrlSetState($radio_6, $GUI_CHECKED)
GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)
; 初始化變量,用于跟蹤 GUI 事件
$radioval1 = 0 ; 我們假定 0 = 第一個(gè)單選按鈕被選中,2 = 最后一個(gè)單選按鈕被選中
$radioval2 = 2
GUISetState ()
; 在下面這個(gè)消息循環(huán)中我們使用了變量來跟蹤單選按鈕的變化,
; 也有其它方法,比如使用 GUICtrlRead() 來讀取每個(gè)控件的狀態(tài),
; 這兩種方法都是可行的
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $button_1
MsgBox(0, "Button", "Radio " & $radioval1 & @LF & "Radio " & Chr($radioval2 + Asc("A")) & @LF & GUICtrlRead($input_1) & @LF & GUICtrlRead($input_2))
Case $msg = $radio_1 OR $msg = $radio_2 OR $msg = $radio_3
$radioval1 = $msg - $radio_1
Case $msg = $radio_4 OR $msg = $radio_5 OR $msg = $radio_6
$radioval2 = $msg - $radio_4
EndSelect
WEnd
当涂县| 治县。| 光泽县| 论坛| 田东县| 东乡| 进贤县| 盐津县| 榆中县| 江孜县| 海安县| 望城县| 甘孜县| 盐亭县| 陆河县| 千阳县| 安福县| 丹巴县| 久治县| 临颍县| 扎囊县| 贺兰县| 商丘市| 嘉祥县| 开阳县| 凌云县| 嘉义县| 阿城市| 崇礼县| 黄龙县| 江华| 泗洪县| 蒙阴县| 五大连池市| 玉田县| 图们市| 武胜县| 宜宾县| 铜鼓县| 忻城县| 偃师市|