Vier Posted May 22, 2006 Posted May 22, 2006 I have a treeview with this two options : $TVS_CHECKBOXES,$TVS_HASBUTTONS.An exemple : I create a function for :- if all child box is check, parent box is check- if all or one child box is uncheck, parent box is unchek- if parent box is check, all child box is check- if parent box is uncheck, all child box is uncheckMy part of function test if parent box is check or uncheck and check/uncheck child box :For $i = 1 to $tree[0][0][0] ; test all TreeViewIf $msg = $tree[$i][0][0] Then ; Parent Treeviewitem If BitAnd(GUICtrlRead($tree[$i][0][0]),$GUI_CHECKED) Then For $j = 1 To $tree[$i][0][3] GUICtrlSetState ($tree[$i][$j][0],$GUI_CHECKED) ; Child TreeviewItem Next ElseIf BitAnd(GUICtrlRead($tree[$i][0][0]),$GUI_UNCHECKED) Then For $j = 1 To $tree[$i][0][3] GUICtrlSetState ($tree[$i][$j][0],$GUI_UNCHECKED) ; Child TreeviewItem Next EndIfEndIfNextMy problem : if I collapse/expand with $TVS_HASBUTTONS, my function test if parent box is check/uncheck and check/uncheck child box. But I don't want when I collpase/expand treeview the test works !Please help me !
alient Posted May 23, 2006 Posted May 23, 2006 Can you also post the code you used to generate your treeview? I need to create something very similar and I don't quite know how to do so. Thanks! I have a treeview with this two options : $TVS_CHECKBOXES,$TVS_HASBUTTONS. An exemple : I create a function for : - if all child box is check, parent box is check - if all or one child box is uncheck, parent box is unchek - if parent box is check, all child box is check - if parent box is uncheck, all child box is uncheck My part of function test if parent box is check or uncheck and check/uncheck child box : For $i = 1 to $tree[0][0][0] ; test all TreeView If $msg = $tree[$i][0][0] Then ; Parent Treeviewitem If BitAnd(GUICtrlRead($tree[$i][0][0]),$GUI_CHECKED) Then For $j = 1 To $tree[$i][0][3] GUICtrlSetState ($tree[$i][$j][0],$GUI_CHECKED) ; Child TreeviewItem Next ElseIf BitAnd(GUICtrlRead($tree[$i][0][0]),$GUI_UNCHECKED) Then For $j = 1 To $tree[$i][0][3] GUICtrlSetState ($tree[$i][$j][0],$GUI_UNCHECKED) ; Child TreeviewItem Next EndIf EndIf Next My problem : if I collapse/expand with $TVS_HASBUTTONS, my function test if parent box is check/uncheck and check/uncheck child box. But I don't want when I collpase/expand treeview the test works ! Please help me !
Vier Posted May 24, 2006 Author Posted May 24, 2006 I'm use a system with read an ini file, like : Func _PersoReseauCreateTree3($ini,$name,$tree2) $ctree = IniReadSection($ini,$name) $a = $ctree[0][0] $b = 0 For $i = 1 To $a $ctree2 = IniReadSection($ini,$ctree[$i][1]) If $ctree2[0][0] > $b Then $b = $ctree2[0][0] Next Dim $ctree3[$a+1][$b+1][4] $ctree3[0][0][0]=$a For $i = 1 To $a $ctree2 = IniReadSection($ini,$ctree[$i][1]) $ctree3[$i][0][3] = $ctree2[0][0] Next For $i = 1 To $ctree3[0][0][0] $ctree3[$i][0][0] = GUICtrlCreateTreeViewitem ($ctree[$i][1],$tree2) $ctree2 = IniReadSection($ini,$ctree[$i][1]) For $j = 1 To $ctree3[$i][0][3] $ctree3[$i][$j][0] = GUICtrlCreateTreeViewitem (IniRead($ini,$ctree2[$j][1],"c",""),$ctree3[$i][0][0]) $ctree3[$i][$j][1] = IniRead($ini,$ctree2[$j][1],"k","") $ctree3[$i][$j][2] = IniRead($ini,$ctree2[$j][1],"d","") Next Next Return $ctree3 EndFunc
JMiller Posted May 25, 2006 Posted May 25, 2006 I had a similar issue. What I did was create an Global array to hold the current state of the upper level items. Then, I set the items state value when it is checked or unchecked. Then, before I check/uncheck the child objects, I see if the state actually changed for the parent item before changing them. If BitAND(GUICtrlRead(@GUI_CtrlID), $GUI_CHECKED) = $GUI_CHECKED And $catStates[$catCounter] <> BitAND(GUICtrlRead(@GUI_CtrlID), $GUI_CHECKED) Then $catStates[$catCounter] = BitAND(GUICtrlRead(@GUI_CtrlID), $GUI_CHECKED) GUICtrlSetState($packElements[$packCounter], $GUI_CHECKED) This isn't really what my code looks like exactly, but I pasted the parts that were relevant.
Vier Posted May 25, 2006 Author Posted May 25, 2006 I have found a solution for my problem : I remove parent checkbox. For this I have found in the forum a function.
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