JoeCool Posted August 3, 2006 Share Posted August 3, 2006 HI :-) Is there something like _guiCtrlTreeViewItemGetParent ( $treeView, $treeViewItem ) somewhere ? Link to comment Share on other sites More sharing options...
Holger Posted August 4, 2006 Share Posted August 4, 2006 Sample: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> opt("MustDeclareVars", 1) Dim $tree, $item1, $subitem1, $subitem2, $item2, $subitem3, $subitem4, $button, $msg, $Status, $parent GUICreate("GuiTreeView Get Parent ID", 392, 254) $tree = GUICtrlCreateTreeView(10, 10, 200, 200) $item1 = GUICtrlCreateTreeViewItem("Mainitem1", $tree) $subitem1 = GUICtrlCreateTreeViewItem("Subitem11", $item1) $subitem2 = GUICtrlCreateTreeViewItem("Subitem12", $item1) $item2 = GUICtrlCreateTreeViewItem("Mainitem2", $tree) $subitem3 = GUICtrlCreateTreeViewItem("Subitem21", $item2) $subitem4 = GUICtrlCreateTreeViewItem("Subitem22", $item2) $button = GUICtrlCreateButton("Check", 220, 100, 70, 20) $Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER)) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button Msgbox(0, "Info", "ParentID from selected: " & _MyGUICtrlTreeViewGetParentID($tree) & @LF & _ "ParentID from $subitem2: " & _MyGUICtrlTreeViewGetParentID($tree, $subitem2)) EndSelect WEnd Exit Func _MyGUICtrlTreeViewGetParentID($nTreeview, $hItem = 0) If $hItem = 0 Then $hItem = GUICtrlSendMsg($nTreeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) Else Local $hItemTmp = GUICtrlGetHandle($hItem) If $hItemTmp <> 0 Then $hItem = $hItemTmp EndIf If $hItem = 0 Then Return 0 Local $hParent = GUICtrlSendMsg($nTreeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) Local $stTVITEM = DllStructCreate("uint;dword;uint;uint;ptr;int;int;int;int;dword") DllStructSetData($stTVITEM, 1, $TVIF_PARAM) DllStructSetData($stTVITEM, 2, $hParent) If GUICtrlSendMsg($nTreeview, $TVM_GETITEM, 0, DllStructGetPtr($stTVITEM)) = 0 Then Return 0 Return DllStructGetData($stTVITEM, 10) EndFunc Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
JoeCool Posted August 4, 2006 Author Share Posted August 4, 2006 (edited) Sample: Func _MyGUICtrlTreeViewGetParentID($nTreeview, $hItem = 0) If $hItem = 0 Then $hItem = GUICtrlSendMsg($nTreeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) Else Local $hItemTmp = GUICtrlGetHandle($hItem) If $hItemTmp <> 0 Then $hItem = $hItemTmp EndIf If $hItem = 0 Then Return 0 Local $hParent = GUICtrlSendMsg($nTreeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) Local $stTVITEM = DllStructCreate("uint;dword;uint;uint;ptr;int;int;int;int;dword") DllStructSetData($stTVITEM, 1, $TVIF_PARAM) DllStructSetData($stTVITEM, 2, $hParent) If GUICtrlSendMsg($nTreeview, $TVM_GETITEM, 0, DllStructGetPtr($stTVITEM)) = 0 Then Return 0 Return DllStructGetData($stTVITEM, 10) EndFunc Hey Thanks ;-) I was in a process to build something like that because I want to find parent treeViewItem of an unselected item, the current UDF only implement for selected item ! I was good until I have to convert the parent handle to an ID . Some people suggest http://www.autoitscript.com/forum/index.php?showtopic=30285My Webpage but it seems that isn't working for treeviewitem .... I'm gonna study your last part of your function ;-) BTW, why not include your function into the current UDF ? Edited August 4, 2006 by JoeCool Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 4, 2006 Moderators Share Posted August 4, 2006 Hey Thanks ;-)I was in a process to build something like that because I want to find parent treeViewItem of an unselecteditem, the current UDF only implement for selected item !I was good until I have to convert the parent handle to an ID .Some people suggest http://www.autoitscript.com/forum/index.php?showtopic=30285My Webpagebut it seems that isn't working for treeviewitem ....I'm gonna study your last part of your function ;-)BTW, why not include your function into the current UDF ?Keep an eye out, if it isn't and Holger wrote it, then it probably will be . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JoeCool Posted August 4, 2006 Author Share Posted August 4, 2006 Keep an eye out, if it isn't and Holger wrote it, then it probably will be .BTW I finish a silly simple script holder using those treeViewItem ,take a peek at http://www.autoitscript.com/forum/index.php?showtopic=30124 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now