treeview如何点击父项获取下面的子项即父项文本,如何点击子项获取父项即子项文本!!#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <GuiTreeView.au3>
#Include <GuiListView.au3>
GUICreate("My GUI with treeview",800,600, -1, -1)
$TreeView = GUICtrlCreateTreeView(124, 152, 417, 145);, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_CHECKBOXES))
$TreeView1_0 = GUICtrlCreateTreeViewItem("用户个人文档:"&@MyDocumentsDir, $TreeView)
$TreeView1_1 = GUICtrlCreateTreeViewItem("转移到:", $TreeView1_0)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GuiSetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom
Case $treeview
Switch $Event; 选择产生的事件
Case $TVN_SELCHANGEDW ; 左击
;MsgBox(0, '', GUICtrlRead(GUICtrlRead($TreeView1)))
If GUICtrlRead($treeview) > 0 Then
$nums = _GUICtrlTreeView_GetText($treeview, GUICtrlRead($treeview))
MsgBox(0,"",$nums)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
|