brian_h

TreeView issues

5 posts in this topic

Hi,

I am using AutoIt to test a program containing a tree view, during which I navigate the tree using the ControlTreeView function.  I control the program to have it add new items to the tree, and I can navigate to these using ControlTreeView with "Expand", "Select", etc.  And if I control the program to have it delete an item from the tree, this is reflected when navigating the tree in AutoIt (using ControlTreeView), however if I delete an item and then add it again, ControlTreeView does not appear to see the new node,

I assume that the nodes are being cached internally, so after deleting a node, its parent node has its child count set to zero in the cache, but when a new item is added via the program it does not change the cache so it cannot be "seen" by AutoIt.

Is this correct, and if so, is there a way to have AuoiIt discard its cache, so that the next time I navigate using ControlTreeView it will get the items from the tree and not the cache?

Thanks,

Brian

Share this post


Link to post
Share on other sites



brian_h,

Welcome to the AutoIt forums.

As far as I know there is no cache within AutoIt - most commands pass directly to Windows via the API. So I feel it is far more likely that Windows itself is caching the treeview state so that AutoIt gets a false return when requesting the new data. Sorry not be of more help - can you let us know the name of the program in question? Perhaps someone else here has some experience of working with it.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Hi M23,

Thanks for the reply, and the welcome.

The program is question is one we write ourselves, and its for a specialized market, so its unlikely anyone else will have experience working with it.

The tree in question is a standard SysTreeView32 tree, and using the ControlTreeView function, I navigate down the tree to the item I want, select it, do some tests, then I execute a command in the program to delete the selected node.  I then select the parent node and check it has a child count of zero, which it does.  I then execute another command to add a new child node (this actually makes a database change and reloads the tree), but when I ask for the child count again it still returns zero, and if I try to expand the parent it returns an error.  However, I can expand the node manually in the program and the child node is there. :(

So at this point I'm a little bit stuck.  I might try writing my own function for expanding the tree by sending messages directly to the it and see if that has any more success.

Thanks.

Brian

Share this post


Link to post
Share on other sites

Take a look at the GuiTreeView UDF. It provides access to many more functions than the few functions that are implemented through ControlTreeView.

Share this post


Link to post
Share on other sites

Thanks LarsJ,

I had already found the GetItemText method in the GuiListView.au3 file, it was a good example of handling the tricky bit of getting the text out (pretty much the same as required for the tree view), which involves creating a struct and copying it to global memory, and using that I managed to write my own Expand method for the tree that takes a path like the one passed to the ControlTreeView method.

When I tried this I got exactly the same issue when trying to expand the parent of the new item in the tree, which convinced me that the problem was in the application and not AutoIt.

After a bit of routing about in the application's source code, I did find the issue - the tree is loaded on demand from the database, so when a node is expanded we handle the notification and load the data for that branch (if any).  When refreshing the tree, we only load the data for already expanded nodes, and set the child count for each leaf node to 1, so that the expand button is shown, and when it's clicked we attempt to load the children, and if there are none we set the child count to 0.  However, it turns out that once a node has been expanded, the item's state gets updated with the TVIS_EXPANDEDONCE state, which tells the tree not to raise the TVN_EXPANDING notification the next time it is expanded, so the new child for the node never got loaded (although clicking on the expand button manually did still load the data!).  I fixed this by clearing this state whenever we set the child count, so the notifications get raised the next time it is expanded, and now my AutoIt script works as it should.

Thanks for the help.

Brian

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