fifi Posted July 6, 2005 Posted July 6, 2005 Hi, is it also possible to count the items of a mainitem? The UDF _GUICtrlTreeViewGetCount in beta 56 does not work if there is given a control-id of a mainitem as param (for example $mainitem2) :-( Has anybody an idea? Thanks FIFI
GaryFrost Posted July 6, 2005 Posted July 6, 2005 (edited) This only counts the children of item selected not it's childrens children etc... 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 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 GUICtrlSetData($Status, "# Children: " & _GUICtrlTreeViewCountChildren($tree)) EndSelect WEnd Exit Func _GUICtrlTreeViewCountChildren($h_treeview) Local $count = 0, $hItem,$h_item $hItem = GUICtrlSendMsg($h_treeview,$TVM_GETNEXTITEM,$TVGN_CARET,0) $h_item = GUICtrlSendMsg($h_treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) Do If ($h_item > 0) Then $count = $count + 1 EndIf $h_item = GUICtrlSendMsg($h_treeview, $TVM_GETNEXTITEM, $TVGN_NEXT, $h_item) Until $h_item <= 0 Return $count EndFunc Edited July 6, 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.
fifi Posted July 7, 2005 Author Posted July 7, 2005 Hi gafrost, works perfectly! Thank you very much. FIFI
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