|
发表于 2011-2-26 00:44:32
|
显示全部楼层
这个方法应该可以的,
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
$Debug_TV = False ; 检查被传递给函数的类名, 设置为True,并使用另一个控件句柄,看看它的工作.
_Main()
Func _Main()
Local $hItem[6], $hRandomItem, $hTreeView
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
GUICreate("树视图函数演示 Set Checked", 400, 300)
$hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
_GUICtrlTreeView_BeginUpdate($hTreeView)
For $x = 0 To UBound($hItem) - 1
$hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] 主项目", $x + 1), $hTreeView)
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
$hRandomItem = Random(0, UBound($hItem) - 1, 1)
MsgBox(4160, "提示", StringFormat("项目 %d 选中吗? %s", $hRandomItem, _GUICtrlTreeView_GetChecked($hTreeView, $hItem[$hRandomItem])))
_GUICtrlTreeView_SetChecked($hTreeView, $hItem[$hRandomItem])
MsgBox(4160, "提示", StringFormat("项目 %d 选中吗? %s", $hRandomItem, _GUICtrlTreeView_GetChecked($hTreeView, $hItem[$hRandomItem])))
; 循环到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main |
|