dazza Posted February 18, 2009 Share Posted February 18, 2009 Using the code in the help files: _GUICtrlTreeView_Create.au3, I can detect when an item in the treeview is checked. However, I haven't a clue how to then check all the children (and grandchildren, great grandchildren et al) nodes below. I humbly await the wisdom of AutoIT gurus. Link to comment Share on other sites More sharing options...
Manjish Posted February 18, 2009 Share Posted February 18, 2009 _GUICtrlTreeView_GetSelection and _GUICtrlTreeView_GetChildren [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
dazza Posted February 19, 2009 Author Share Posted February 19, 2009 Ack. I've rummaged through these references; I still can't see how to do it Someone please show me the code how to do it. It's probably quite simple--like me. Ta Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 19, 2009 Share Posted February 19, 2009 Ack. I've rummaged through these references; I still can't see how to do it Someone please show me the code how to do it. It's probably quite simple--like me. Ta This is a modified version of the example script for _GUICtrlTreeView_GetNextChild(): #include <GuiConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Global $hItem[6], $hTreeView, $iRandomItem, $hRandomItem, $hFirstChild, $sFirstChild, $hNextChild, $sNextChild, $sMsg Global $iStyle = BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS) GUICreate("TreeView Get Next Child", 400, 300) $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 0 To UBound($hItem) - 1 $hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $hTreeView) For $y = 0 To 2 GUICtrlCreateTreeViewItem(StringFormat("[%02d-%02d] New Child Item", $x, $y), $hItem[$x]) Next Next _GUICtrlTreeView_EndUpdate($hTreeView) $iRandomItem = Random(0, UBound($hItem) - 1, 1) $ctrlRandomItem = $hItem[$iRandomItem] $sMsg &= "Randomly selected item = " & $iRandomItem & ", control ID = " & $ctrlRandomItem & @CRLF $hFirstChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $ctrlRandomItem) $sFirstChild = _GUICtrlTreeView_GetText($hTreeView, $hFirstChild) $sMsg &= "First child handle = " & $hFirstChild & ", text = " & $sFirstChild & @CRLF $hNextChild = _GUICtrlTreeView_GetNextChild($hTreeView, $hFirstChild) $sNextChild = _GUICtrlTreeView_GetText($hTreeView, $hNextChild) _GUICtrlTreeView_SelectItem($hTreeView, $hNextChild) $sMsg &= "Next child handle = " & $hNextChild & ", text = " & $sNextChild MsgBox(64, "_GuiCtrlTreeView_GetNextChild()", $sMsg) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE You have my empathy if some of this is confusing. Some of the examples in the help file have extraneous stuff thrown in, and Control IDs and control handles are mixed where the parameters say you can only use one. You want to get the control ID or handle for the parent item, then get the handle for the first child item, then a loop can get the next child/sibling until you have what you want. This demo only gets the first child and the next. You would have to add a loop to get them all. Note _GuiCtrlTreeView_GetNextChild() is just an alias for _GuiCtrlTreeView_GetNextSibling(), added for consistency in the naming convention, I guess. If that doesn't help, try to ask a more specific question about the part you don't understand. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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