DjDeep00 Posted June 8, 2007 Share Posted June 8, 2007 Thanks to Holger...I have most of the functionality that I want working but for some reason after I choose my child treeview items and then click on the parent all the checkboxes get wiped out. Please Holger or somebody please tell what I am doing wrong...Here is the script.. expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> $TV_FIRST = 0x1100 $TVM_GETNEXTITEM = $TV_FIRST + 10 $TVM_GETITEM = $TV_FIRST + 12 $TVGN_NEXT = 0x0001 $TVGN_PARENT = 0x0003 $TVGN_CHILD = 0x0004 $TVGN_CARET = 0x0009 $TVIF_PARAM = 0x0004 GUICreate("Treeview Checkbox Test",200,200) $Parent="A|B|C" $Parent_Split=StringSplit($Parent,"|") $Child="Child1|Child2|Child3" $Child_Split=StringSplit($Child,"|") Global $Treeview=GUICtrlCreateTreeView(20,20,150,150,BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) Dim $Tree_Parent_Split[$Parent_Split[0]+1] Dim $Tree_Child_Split[$Child_Split[0]+1] For $x=1 to $Parent_Split[0] $Tree_Parent_Split[$x]=GUICtrlCreateTreeViewItem($Parent_Split[$x],$Treeview) For $y=1 to $Child_Split[0] $Tree_Child_Split[$y]=GUICtrlCreateTreeViewItem($Child_Split[$y],$Tree_Parent_Split[$x]) Next Next GUISetState() While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE ExitLoop Case $Msg >= $Tree_Parent_Split[1] If BitAnd(GUICtrlRead($Msg), $GUI_INDETERMINATE) Then ContinueLoop; Do nothing when in indeterminate state $hItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) If $hItem > 0 Then $hChildItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then CheckChilds($Treeview, $hChildItem, BitAnd(GUICtrlRead($Msg), $GUI_CHECKED)) $hParentItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) If $hParentItem > 0 Then GetParents($Treeview, $hParentItem, BitAnd(GUICtrlRead($Msg), $GUI_CHECKED)) EndIf EndSelect WEnd Func CheckChilds($nCtrl, $hItem, $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) $arr = GUICtrlRead($nItem ,1) GUICtrlSetState($nItem, $nCheck * -3 + $GUI_UNCHECKED) ; Same like: GUICtrlSetState($nItem, BitOr(BitAnd($nCheck, $GUI_UNCHECKED), BitAnd($nCheck, $GUI_CHECKED))) $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then CheckChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;********************************************************** ; Check/set state of the parent items until root ;********************************************************** Func GetParents($nCtrl, $hItem, $nCheck) While $hItem > 0 $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) $nState = $nCheck * -3 + $GUI_UNCHECKED $nCheckState = $nState If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheckState) $nItem = GetItemID($nCtrl, $hItem) $arInfo = GUICtrlRead($nItem,1) If $nCheckState Then GUICtrlSetState($nItem, $nState) Else GUICtrlSetState($nItem, $GUI_INDETERMINATE) EndIf $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) WEnd EndFunc ;********************************************************** ; Gets state of the child items in the subtree ;********************************************************** Func GetChilds($nCtrl, $hItem, ByRef $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) If Not BitAnd(GUICtrlRead($nItem), $nCheck) Then $nCheck = 0 ExitLoop EndIf $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;********************************************************** ; Returns the CtrlID by a given treeitem-handle ;********************************************************** Func GetItemID($Ctrl, $hItem) $nID = 0 $hTree = ControlGetHandle("", "", $Ctrl) $TVITEM = DllStructCreate ("uint;int;uint;uint;ptr;int;int;int;int;int") If @error Then DllStructDelete ($TVITEM) Return $nID EndIf DllStructSetData ($TVITEM, 1, $TVIF_PARAM) DllStructSetData ($TVITEM, 2, $hItem) $nResult = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTree, "int", $TVM_GETITEM, "int", 0, "ptr", DllStructGetPtr($TVITEM)) If ($nResult[0]) Then $nID = DllStructGetData($TVITEM, 10) EndIf ;DllStructDelete($TVITEM) Return $nID EndFunc Thanks Link to comment Share on other sites More sharing options...
MHz Posted June 8, 2007 Share Posted June 8, 2007 Thanks to Holger...I have most of the functionality that I want working but for some reason after I choose my child treeview items and then click on the parent all the checkboxes get wiped out. Please Holger or somebody please tell what I am doing wrong...Here is the script..I do not see the issue using AutoIt 3.2.4.9. DllStructDelete() does not exist anymore and the variables at the top of your script are already defined as Global Const variables in the includes. expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> GUICreate("Treeview Checkbox Test",200,200) $Parent="A|B|C" $Parent_Split=StringSplit($Parent,"|") $Child="Child1|Child2|Child3" $Child_Split=StringSplit($Child,"|") Global $Treeview=GUICtrlCreateTreeView(20,20,150,150,BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) Dim $Tree_Parent_Split[$Parent_Split[0]+1] Dim $Tree_Child_Split[$Child_Split[0]+1] For $x=1 to $Parent_Split[0] $Tree_Parent_Split[$x]=GUICtrlCreateTreeViewItem($Parent_Split[$x],$Treeview) For $y=1 to $Child_Split[0] $Tree_Child_Split[$y]=GUICtrlCreateTreeViewItem($Child_Split[$y],$Tree_Parent_Split[$x]) Next Next GUISetState() While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE ExitLoop Case $Msg >= $Tree_Parent_Split[1] If BitAnd(GUICtrlRead($Msg), $GUI_INDETERMINATE) Then ContinueLoop; Do nothing when in indeterminate state $hItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) If $hItem > 0 Then $hChildItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then CheckChilds($Treeview, $hChildItem, BitAnd(GUICtrlRead($Msg), $GUI_CHECKED)) $hParentItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) If $hParentItem > 0 Then GetParents($Treeview, $hParentItem, BitAnd(GUICtrlRead($Msg), $GUI_CHECKED)) EndIf EndSelect WEnd Func CheckChilds($nCtrl, $hItem, $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) $arr = GUICtrlRead($nItem ,1) GUICtrlSetState($nItem, $nCheck * -3 + $GUI_UNCHECKED) ; Same like: GUICtrlSetState($nItem, BitOr(BitAnd($nCheck, $GUI_UNCHECKED), BitAnd($nCheck, $GUI_CHECKED))) $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then CheckChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;********************************************************** ; Check/set state of the parent items until root ;********************************************************** Func GetParents($nCtrl, $hItem, $nCheck) While $hItem > 0 $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) $nState = $nCheck * -3 + $GUI_UNCHECKED $nCheckState = $nState If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheckState) $nItem = GetItemID($nCtrl, $hItem) $arInfo = GUICtrlRead($nItem,1) If $nCheckState Then GUICtrlSetState($nItem, $nState) Else GUICtrlSetState($nItem, $GUI_INDETERMINATE) EndIf $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) WEnd EndFunc ;********************************************************** ; Gets state of the child items in the subtree ;********************************************************** Func GetChilds($nCtrl, $hItem, ByRef $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) If Not BitAnd(GUICtrlRead($nItem), $nCheck) Then $nCheck = 0 ExitLoop EndIf $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;********************************************************** ; Returns the CtrlID by a given treeitem-handle ;********************************************************** Func GetItemID($Ctrl, $hItem) $nID = 0 $hTree = ControlGetHandle("", "", $Ctrl) $TVITEM = DllStructCreate ("uint;int;uint;uint;ptr;int;int;int;int;int") If @error Then $TVITEM = 0 Return $nID EndIf DllStructSetData ($TVITEM, 1, $TVIF_PARAM) DllStructSetData ($TVITEM, 2, $hItem) $nResult = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTree, "int", $TVM_GETITEM, "int", 0, "ptr", DllStructGetPtr($TVITEM)) If ($nResult[0]) Then $nID = DllStructGetData($TVITEM, 10) EndIf ;DllStructDelete($TVITEM) Return $nID EndFunc Link to comment Share on other sites More sharing options...
DjDeep00 Posted June 8, 2007 Author Share Posted June 8, 2007 MHZ...Thanks for the quick reply...I was using a very old beta but after trying the code using the new beta (3.2.3.14)..I still can't get it to work...Here is exactly what I am doing... 1. Click on the + to expand A (Don't check A) 2. Check items "Child2" and "Child3". 3. Click on the - to collapse A (Don't check A) 4. Now click on the + to expand A again and your checked items are unchecked. I hope you are able to reproduce this. Thanks. Link to comment Share on other sites More sharing options...
MHz Posted June 8, 2007 Share Posted June 8, 2007 (edited) ...and your checked items are unchecked.Oh, yes, see it now. They are unchecked when collapsed again. You wipe out description led to other ideas. Will look more into it. And AutoIt public release version is latest. Edit: There is a issue with the CheckChilds() function changing the state of the checkboxes. I have commented the call to the function in the message loop to solve. expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> GUICreate("Treeview Checkbox Test", 200, 200) $Parent = "A|B|C" $Parent_Split = StringSplit($Parent, "|") $Child = "Child1|Child2|Child3" $Child_Split = StringSplit($Child, "|") Global $Treeview = GUICtrlCreateTreeView(20, 20, 150, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) Dim $Tree_Parent_Split[$Parent_Split[0] + 1] Dim $Tree_Child_Split[$Child_Split[0] + 1] For $x = 1 To $Parent_Split[0] $Tree_Parent_Split[$x] = GUICtrlCreateTreeViewItem($Parent_Split[$x], $Treeview) For $y = 1 To $Child_Split[0] $Tree_Child_Split[$y] = GUICtrlCreateTreeViewItem($Child_Split[$y], $Tree_Parent_Split[$x]) Next Next GUISetState() While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE ExitLoop Case $Msg >= $Tree_Parent_Split[1] If BitAND(GUICtrlRead($Msg), $GUI_INDETERMINATE) Then ContinueLoop; Do nothing when in indeterminate state $hItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) If $hItem > 0 Then $hChildItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) ;~ If $hChildItem > 0 Then CheckChilds($Treeview, $hChildItem, BitAND(GUICtrlRead($Msg), $GUI_CHECKED)) $hParentItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) If $hParentItem > 0 Then GetParents($Treeview, $hParentItem, BitAND(GUICtrlRead($Msg), $GUI_CHECKED)) EndIf EndSelect WEnd Func CheckChilds($nCtrl, $hItem, $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) $arr = GUICtrlRead($nItem, 1) GUICtrlSetState($nItem, $nCheck * - 3 + $GUI_UNCHECKED) ; Same like: GUICtrlSetState($nItem, BitOr(BitAnd($nCheck, $GUI_UNCHECKED), BitAnd($nCheck, $GUI_CHECKED))) $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then CheckChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;==>CheckChilds ;********************************************************** ; Check/set state of the parent items until root ;********************************************************** Func GetParents($nCtrl, $hItem, $nCheck) While $hItem > 0 $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) $nState = $nCheck * - 3 + $GUI_UNCHECKED $nCheckState = $nState If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheckState) $nItem = GetItemID($nCtrl, $hItem) $arInfo = GUICtrlRead($nItem, 1) If $nCheckState Then GUICtrlSetState($nItem, $nState) Else GUICtrlSetState($nItem, $GUI_INDETERMINATE) EndIf $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) WEnd EndFunc ;==>GetParents ;********************************************************** ; Gets state of the child items in the subtree ;********************************************************** Func GetChilds($nCtrl, $hItem, ByRef $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) If Not BitAND(GUICtrlRead($nItem), $nCheck) Then $nCheck = 0 ExitLoop EndIf $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;==>GetChilds ;********************************************************** ; Returns the CtrlID by a given treeitem-handle ;********************************************************** Func GetItemID($Ctrl, $hItem) $nID = 0 $hTree = ControlGetHandle("", "", $Ctrl) $TVITEM = DllStructCreate("uint;int;uint;uint;ptr;int;int;int;int;int") If @error Then $TVITEM = 0 Return $nID EndIf DllStructSetData($TVITEM, 1, $TVIF_PARAM) DllStructSetData($TVITEM, 2, $hItem) $nResult = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTree, "int", $TVM_GETITEM, "int", 0, "ptr", DllStructGetPtr($TVITEM)) If ($nResult[0]) Then $nID = DllStructGetData($TVITEM, 10) EndIf ;DllStructDelete($TVITEM) Return $nID EndFunc ;==>GetItemID Edited June 8, 2007 by MHz Link to comment Share on other sites More sharing options...
MHz Posted June 8, 2007 Share Posted June 8, 2007 Here, I added some functions from Holger's TriStateTreeviewLib.au3 that I have used before and the result seems ok. Holger even uses pictures in it to make the main branch checkbox look indeterminate. Worth a look.expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> GUICreate("Treeview Checkbox Test", 200, 200) $Parent = "A|B|C" $Parent_Split = StringSplit($Parent, "|") $Child = "Child1|Child2|Child3" $Child_Split = StringSplit($Child, "|") Global $Treeview = GUICtrlCreateTreeView(20, 20, 150, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) Dim $Tree_Parent_Split[$Parent_Split[0] + 1] Dim $Tree_Child_Split[$Child_Split[0] + 1] For $x = 1 To $Parent_Split[0] $Tree_Parent_Split[$x] = GUICtrlCreateTreeViewItem($Parent_Split[$x], $Treeview) For $y = 1 To $Child_Split[0] $Tree_Child_Split[$y] = GUICtrlCreateTreeViewItem($Child_Split[$y], $Tree_Parent_Split[$x]) Next Next GUISetState() While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE ExitLoop Case $Msg >= $Tree_Parent_Split[1] If BitAND(GUICtrlRead($Msg), $GUI_INDETERMINATE) Then ContinueLoop; Do nothing when in indeterminate state $hItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0) If $hItem > 0 Then $hChildItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then CheckChildItems($Treeview, $hChildItem, BitAND(GUICtrlRead($Msg), $GUI_CHECKED)) $hParentItem = GUICtrlSendMsg($Treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) If $hParentItem > 0 Then GetParents($Treeview, $hParentItem, BitAND(GUICtrlRead($Msg), $GUI_CHECKED)) EndIf EndSelect WEnd ;********************************************************** ; Helper functions ;********************************************************** Func CheckChildItems($hWnd, $hItem, $nState) Local $hChild = SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) While $hChild > 0 SetItemState($hWnd, $hChild, $nState) CheckChildItems($hWnd, $hChild, $nState) $hChild = SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_NEXT, $hChild) WEnd EndFunc Func SendMessage($hWnd, $Msg, $wParam, $lParam) $nResult = DllCall("user32.dll", "int", "SendMessage", _ "hwnd", $hWnd, _ "int", $Msg, _ "int", $wParam, _ "int", $lParam) Return $nResult[0] EndFunc Func SetItemState($hWnd, $hItem, $nState) $nState = BitShift($nState, -12) Local $tvItem = DllStructCreate("uint;dword;uint;uint;ptr;int;int;int;int;int;int") DllStructSetData($tvItem, 1, $TVIF_STATE) DllStructSetData($tvItem, 2, $hItem) DllStructSetData($tvItem, 3, $nState) DllStructSetData($tvItem, 4, $TVIS_STATEIMAGEMASK) SendMessage($hWnd, $TVM_SETITEM, 0, DllStructGetPtr($tvItem)) EndFunc ;~ Func CheckChilds($nCtrl, $hItem, $nCheck) ;~ While $hItem > 0 ;~ $nItem = GetItemID($nCtrl, $hItem) ;~ $arr = GUICtrlRead($nItem, 1) ;~ GUICtrlSetState($nItem, $nCheck * - 3 + $GUI_UNCHECKED) ;~ ; Same like: GUICtrlSetState($nItem, BitOr(BitAnd($nCheck, $GUI_UNCHECKED), BitAnd($nCheck, $GUI_CHECKED))) ;~ $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) ;~ If $hChildItem > 0 Then CheckChilds($nCtrl, $hChildItem, $nCheck) ;~ $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) ;~ WEnd ;~ EndFunc ;==>CheckChilds ;********************************************************** ; Check/set state of the parent items until root ;********************************************************** Func GetParents($nCtrl, $hItem, $nCheck) While $hItem > 0 $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) $nState = $nCheck * - 3 + $GUI_UNCHECKED $nCheckState = $nState If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheckState) $nItem = GetItemID($nCtrl, $hItem) $arInfo = GUICtrlRead($nItem, 1) If $nCheckState Then GUICtrlSetState($nItem, $nState) Else GUICtrlSetState($nItem, $GUI_INDETERMINATE) EndIf $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem) WEnd EndFunc ;==>GetParents ;********************************************************** ; Gets state of the child items in the subtree ;********************************************************** Func GetChilds($nCtrl, $hItem, ByRef $nCheck) While $hItem > 0 $nItem = GetItemID($nCtrl, $hItem) If Not BitAND(GUICtrlRead($nItem), $nCheck) Then $nCheck = 0 ExitLoop EndIf $hChildItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem) If $hChildItem > 0 Then GetChilds($nCtrl, $hChildItem, $nCheck) $hItem = GUICtrlSendMsg($nCtrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem) WEnd EndFunc ;==>GetChilds ;********************************************************** ; Returns the CtrlID by a given treeitem-handle ;********************************************************** Func GetItemID($Ctrl, $hItem) $nID = 0 $hTree = ControlGetHandle("", "", $Ctrl) $TVITEM = DllStructCreate("uint;int;uint;uint;ptr;int;int;int;int;int") If @error Then $TVITEM = 0 Return $nID EndIf DllStructSetData($TVITEM, 1, $TVIF_PARAM) DllStructSetData($TVITEM, 2, $hItem) $nResult = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTree, "int", $TVM_GETITEM, "int", 0, "ptr", DllStructGetPtr($TVITEM)) If ($nResult[0]) Then $nID = DllStructGetData($TVITEM, 10) EndIf ;DllStructDelete($TVITEM) Return $nID EndFunc ;==>GetItemID Link to comment Share on other sites More sharing options...
DjDeep00 Posted June 8, 2007 Author Share Posted June 8, 2007 MHz...Thanks for helping me out with this...The only one thing that is not working rite now is if you check the parent, the child items dont get selected. Also how would you read the treeview control?...Meaning is there some function that would return an array of all the items that are check in the treeview?... Thanks. Link to comment Share on other sites More sharing options...
MHz Posted June 8, 2007 Share Posted June 8, 2007 Try these changes with the Tri-State checkboxes. GuiScript.zip Link to comment Share on other sites More sharing options...
DjDeep00 Posted June 8, 2007 Author Share Posted June 8, 2007 Thanks again MHz...The only thing left now is to read whatever I checked....Let me fool around with that...Just a warning...I might bug you again. Link to comment Share on other sites More sharing options...
MHz Posted June 9, 2007 Share Posted June 9, 2007 Use GuiCtrlRead() to see if they are checked. You can also use advanced parameter of GuiCtrlRead() to read the text from the item. A treeview control can hold lots of items so would suggest arrays to handle them in loops to process. Also have a good look through the standard UDFs for handling treeviews as you may certainly will need to use them. Link to comment Share on other sites More sharing options...
DjDeep00 Posted June 14, 2007 Author Share Posted June 14, 2007 Use GuiCtrlRead() to see if they are checked. You can also use advanced parameter of GuiCtrlRead() to read the text from the item.A treeview control can hold lots of items so would suggest arrays to handle them in loops to process. Also have a good look through the standard UDFs for handling treeviews as you may certainly will need to use them.Mhz...When you manually check one of the child items of a Parent, the parent has the picture inside the checkbox to show you that only one of the child items is selected...How can I do this by using Guictrlsetstate or is there another way? Link to comment Share on other sites More sharing options...
MHz Posted June 15, 2007 Share Posted June 15, 2007 Mhz...When you manually check one of the child items of a Parent, the parent has the picture inside the checkbox to show you that only one of the child items is selected...How can I do this by using Guictrlsetstate or is there another way?So are you asking for a method of setting a child item as checked/unchecked within the script and to set the parent to the correct state to reflect the change? Link to comment Share on other sites More sharing options...
DjDeep00 Posted June 18, 2007 Author Share Posted June 18, 2007 MHz....sorry for delayed response...yes that is exactly what I am trying todo. I am fooling around with Guictrlsetstate and _GUICtrlTreeViewGetParentID. I think i have figured it out. Let me see if I can cook it up myself and if I get stuck..then i will bug you MHz...thanks again. Link to comment Share on other sites More sharing options...
randallc Posted June 18, 2007 Share Posted June 18, 2007 I am fooling around with Guictrlsetstate and _GUICtrlTreeViewGetParentID. I think i have figured it out. Let me see if I can cook it up myselfHi, that wold be useful to see if you get it going.TIA and Best, Randall! ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW 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