fifi Posted July 8, 2005 Share Posted July 8, 2005 Hi, again i have a special "problem". I tried very hard to build a UDF for treeview which returns the ordnernumber of the clicked subitem, but i had no success after some hours of work. I try to explain this problem: - Mainitem1 -----Subitem11 -----Subitem12 - Mainitem2 -----Subitem21 -----Subitem22 -----Subitem23 - Mainitem3 For example if Subitem22 is clicked i need to know that it is the second Subitem. So the UDF should return "2". And so on! Maybe there is a simple way to do this; based on the functions that holger and gafrost have made for treeview the last days? Thanks FIFI Link to comment Share on other sites More sharing options...
GaryFrost Posted July 8, 2005 Share Posted July 8, 2005 (edited) expandcollapse popup#include <GUIConstants.au3> #include <GuiTreeView.au3> opt ("MustDeclareVars", 1) Dim $tree, $item1, $subitem1, $subitem2, $item2, $subitem3, $subitem4, $button, $msg, $Status, $parent GUICreate("GuiTreeView Child #", 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 GUICtrlSetData($Status, "Child #: " & _GUICtrlTreeViewSubItemSelected($tree)) EndSelect WEnd Exit Func _GUICtrlTreeViewSubItemSelected($h_treeview) Local $count = 1, $h_PItem, $hItem, $h_item $hItem = GUICtrlSendMsg($h_treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) If $hItem == 0 Then Return 0 $h_PItem = GUICtrlSendMsg($h_treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) $h_item = GUICtrlSendMsg($h_treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $h_PItem) Do If ($h_item > 0 And $hItem <> $h_item) Then $h_item = GUICtrlSendMsg($h_treeview, $TVM_GETNEXTITEM, $TVGN_NEXT, $h_item) $count = $count + 1 Else ExitLoop EndIf Until $h_item == 0 Return $count EndFunc ;==>_GUICtrlTreeViewSubItemSelected Edited July 8, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
fifi Posted July 11, 2005 Author Share Posted July 11, 2005 Hi gafrost, thanks for quick helping. Hope this was the last enhancement i needed for treeview. It works perfectly and i think for other users can your UDF's also be very usefull. FIFI 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