Sign in to follow this  
Followers 0
loganhunter2009

GUICtrlTreeView problems

2 posts in this topic

I'm still a bit new to the GUICtrlTreeView and I have some problems.  I am trying to write a script to select multiple items in the tree view of an application but it doesn't seems to be able to to.  I've tried to get the handle using  _GUICtrlTreeView_FindItem but it can't find the item and then I've tried _GUICtrlTreeView_GetFirstItem which returns the first item in the tree.

The first question is why does _GUICtrlTreeView_GetFirstItem not work?  The application is 64-bit so is it not compatible? 

My second question is that using _GUICtrlTreeView_SetSelected to multiselect items in the tree doesn't work.  However, when I use _GUICtrlTreeView_SelectItem, it works but only selects one item. 

I've included my code below.  Thanks in advance.

#include <GUIConstantsEx.au3>
#include <GUITreeView.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIDataSeparatorChar", "\")

Global $hWnd = ControlGetHandle("[CLASS:ORALTClass; TITLE:LightTools]", "", "[CLASS:SysTreeView32; INSTANCE:3]")

$GetHandleCount = ControlTreeView("[CLASS:ORALTClass; TITLE:LightTools]", "", $hWnd, "GetItemCount")

; Returns Window Handle is 0x00AC0018
ConsoleWrite ("Window Handle is " & $hWnd & @CRLF)

; Returns Number of item in tree is 9
ConsoleWrite ("Number of item in tree is " & $GetHandleCount & @CRLF)

$hSelected_Item = _GUICtrlTreeView_GetSelection($hWnd)
$hTest = _GUICtrlTreeView_FindItem($hWnd, "Cube_7")

; Returns Not Found
if $hTest Then
    ConsoleWrite("Found hTest at " & $hTest & @CRLF)
Else
    ConsoleWrite("Not Found" & @CRLF)
EndIf

; Go to Components list
$hItem = _GUICtrlTreeView_GetFirstItem($hWnd)

; Get the first item under the Components Tree
$hChild = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)

; Get the next item under the Components Tree
$hNextChild = _GUICtrlTreeView_GetNextChild($hWnd, $hChild)
$hNextChildCount = _GUICtrlTreeView_GetChildCount($hWnd, $hNextChild)

$hNext2Child = _GUICtrlTreeView_GetNextSibling($hWnd,$hChild)

$ExpandTest = _GUICtrlTreeView_Expand($hWnd, $hChild)

; Returns Item Handle 1 is 0x468FC400
ConsoleWrite ("Item Handle 1 is " & $hItem & @CRLF)
; Returns Child Handle 1 is 0x468B01A0
ConsoleWrite ("Child Handle 1 is " & $hChild & @CRLF)
; Returns Child Count is 2
ConsoleWrite ("Child Count is " & $hNextChildCount & @CRLF)

_GUICtrlTreeView_SetSelected($hWnd, $hChild)
_GUICtrlTreeView_SetSelected($hWnd, $hNextChild)

; This works
_GUICtrlTreeView_SelectItem($hWnd, $hChild)

; Returns hChild State = 0
ConsoleWrite ("hChild State = " & _GUICtrlTreeView_GetState($hWnd, $hChild) & @CRLF)
; Returns hNextChild State = 0
ConsoleWrite ("hNextChild State = " & _GUICtrlTreeView_GetState($hWnd, $hNextChild) & @CRLF)

Share this post


Link to post
Share on other sites



I'm not so sure TreeView's support multiple select.  Does the treeview you are using utilize checkboxes?

Perhaps a loop through the treeview and collecting the results from _GetChecked is what you are looking for?

As far as I know _GetSelection (at least according to the help file), "Retrieves the currently selected item".

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0