问题解决啦,特把解决办法贴上供有需要朋友学习。#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
GUICreate("TreeView",400,300)
$hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268)
GUISetState()
For $x = 1 To 10
$hItem=GUICtrlCreateTreeViewItem($hTreeView,"item"&$x)
For $y = 1 To 3
GUICtrlCreateTreeViewItem($hItem,"child"&$y)
Next
Next
while 1
if guigetmsg()=-3 then
$text=_guictrltreeview_getparenttext($hTreeview,_guictrltreeview_getselection($hTreeview))
msgbox(0,'所在分类名',$text)
exit
endif
wend
func _guictrltreeview_getparenttext($hTreeView,$hItem)
if _guictrltreeview_getchildren($hTreeView,$hItem) then return ""
while $hItem<>0x00000000
$hItem=_guictrltreeview_getprev($hTreeView,$hItem)
if _guictrltreeview_getchildren($hTreeView,$hItem) then return _guictrltreeview_gettext($hTreeView,$hiTem)
wend
return ""
endfunc;getparenttext
|