请教TreeViewItem 控件返回值的问题 “已解决”
本帖最后由 nuoyan 于 2021-9-10 23:30 编辑#include <File.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
$Form1 = GUICreate("Form1", 627, 569)
$TreeView1 = GUICtrlCreateTreeView(8, 8, 177, 481, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("目录列表", $TreeView1)
GUICtrlSetColor(-1, 0x0000C0)
$startlabel = GUICtrlCreateLabel("", 290, 90, 100, 20)
$FileList = _FileListToArray(@WindowsDir , "*" , 2)
For $y = 1 To $FileList
$Child=GUICtrlCreateTreeViewItem($FileList[$y],$generalitem)
Next
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
鼠标点击子项 ,静态标签文本显示为子项名称,不知道 $Child 值要怎么处理了。麻烦大佬帮忙解答下。
加两行代码
在主循环里添加一个 Case
Case $Child - $FileList To $Child
GUICtrlSetData($startlabel, GUICtrlRead($nMsg, 1)) 解决了。感谢。
页:
[1]