Function Reference

TreeViewItem


Creates an item-reference that can be used in Control[Sys]TreeView.

(As such, this function adds no functionality to your code. But it does add clarity and ease of coding, which makes your code easier to debug/maintain/extend. ie. It saves you having to remember how to format an item-reference in AutoIt!)

#include <r_SysTreeView.au3>
TreeViewItem ( [TextOrNumber1 [, TextOrNumber2 [, ... TextOrNumber6]]] )

Parameters

TextOrNumber A string or a number to represent a particular item in the TreeView at this particular level.
  • If you supply a string, this is the text that is displayed on the item.
  • If you supply a number, this is a 0-based index number, ie a count, to refer to the item independently of the text on the item.
The first TextOrNumber specifies an item in the first level of the tree;
each following TextOrNumber specifies an item in the next level down.

Up to 6 TextOrNumbers can be supplied. (ie. You can deal with 6 levels of a TreeView)


Return Value

Returns a string formatted to meet AutoIt's Control[Sys]TreeView "item" parameter.
Forgetting to supply any parameters is safe - it provides an item reference that points at the first item in the root of your treeview.


Explanation

Here is a fictional tree similar to Explorer's FolderOptions...

File Options
----> Display the contents
----> Display the full path
----> Hidden files
----> ----> Show them
----> ----> Hide them
Folder Options
----> Each folder in a separate window

To refer to the item that shows the full path of files, you could use code like...
TreeViewItem( "File Options", "Display the full path" )

To refer to the item that shows hidden files, you could use code like...
TreeViewItem( "File Options", "Hidden files", 0 )


Remarks

As AutoIt is a 32-bit application some commands are not available when referencing a 64-bit application as Explorer when running on 64-bit Windows.


Related

ControlTreeView, ControlSysTreeView


Example

; Author: RAC
#include <r_SysTreeView.au3>

;<--- code to navigate to the example tree above --->

Const $OUR_WINDOW = "[TITLE:Folder Options]"
Const $OUR_TREEVIEW = "[CLASS:SysTreeView32; ID:1123]"

;to definitely display the full path of files
ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "Check", TreeViewItem( "File Options", "Display the full path" ) )

;to find out if they want to see hidden files
$WantSeeHiddenFiles = ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "IsChecked", TreeViewItem( "File Options", "Hidden files", 0 ) )

;to collapse the FileOptions
ControlSysTreeView($OUR_WINDOW, "", $OUR_TREEVIEW, "Collapse", TreeViewItem() )
;no parameter in TreeViewItem = the first item in the root.