Location

WWW

Interests

Hello,
I am having great difficulty with something I would have thought to be fairly easy. I have an array containing (military) organization strings, similar to this:
42nd Battalion
Company A
1st Platoon
1st Squad
2nd Squad
3rd Squad
2nd Platoon
...1st, 2nd, 3rd Squad
3rd Platoon
...1st, 2nd, 3rd Squad
Company B
...etc...
I also have an associated array that contains the 'hierarchy' information associated with each string..."0", "1","2", etc ...therefore using example above the "0" would associate with "42nd Battalion", while "1" would be "Company A", "2" is "1st Platoon", etc. Each sequential number is a 'child' of the preceding number. Therefore the information above would appear in the array as "0", "1", "2", "3", "3", "3", "2", "3", "3", "3", "2", "3", "3", "3", "1", etc...
My issue is that I'm having great difficulty creating a 'Treeview' control using this information. Mainly due to the fact that entries can, and will...repeat (for example multiple entries for "Company A", "Company B", "1st Platoon", "1st Squad", etc, etc). The following code is operative, however it does not create the treeview items as 'child' entries of one another...it simply lists each item as a separate entity.
For $_populate = 0 to Ubound($_HIERARCHY) - 1
_GUICtrlTreeView_BeginUpdate($idTreeView)
_GUICtrlTreeView_Add($idTreeView, $_HIERARCHY[$_populate], String($_STRUCTURES[$_populate]))
_GUICtrlTreeView_EndUpdate($idTreeView)
Next ;Next $_populate, cycle thru '$_HIERARCHY' array to build 'TREEVIEW' Controls
As I mentioned earlier I thought I could manage this...however i'm pulling out quite a bit of my hair trying to get this working properly...any help would be appreciated. I thank you in advance.

Hello,
i stuck again,
Im using this function to create a treeview from root dir.
;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139
#include <File.au3>
#include <WindowsConstants.au3>
Global $sPath = @ScriptDir
Global $hGui = GUICreate('TreeView-Example', 400, 600)
Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE)
GUISetState()
_CreatePath($sPath, $idTreeView)
Do
Until GUIGetMsg() = -3
Func _CreatePath($sPath, $idParent)
Local $aFolder, $aFiles, $idItem
If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
$aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS)
If Not @error Then
For $i = 1 To $aFolder[0]
$idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent)
_CreatePath($sPath & $aFolder[$i], $idItem)
Next
EndIf
$aFiles = _FileListToArray($sPath, '*', $FLTA_FILES)
If @error Then Return
For $i = 1 To $aFiles[0]
$idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent)
Next
EndFunc
Folder Structure:
Folder1
Folder2
Folder3
If a file exists in multiple folders, i like to color it red, if not green.
I know how to do this for files, but nut for the folders.
Because if there is only 1 file in Folder2 that is also in Folder1 that it should only color this single file red, inlcuding its whole tree.
The Folder1 and Folder2 should be red in this case, too. Other files and trees should stay green.
Edit:
Basically i like to color a file and its belonging tree red if the file exists more than 1 time.

Hello,
im searching like 6 hours and i didnt found the right solution.
Im trying to build a treeview from a directory and its subfolders etc.
This function give me right treeview, but i cant color each item seperated.
#include <GuiTreeView.au3>
$hGui = GUICreate("Demo1", 600, 400)
$hTreeView = _GUICtrlTreeView_Create($hGui, 10, 10, 580, 380)
GUISetState()
_GUICtrlTreeView_BeginUpdate($hTreeView)
ListFiles_ToTreeView(@ScriptDir, 0)
_GUICtrlTreeView_EndUpdate($hTreeView)
Do
Until GUIGetMsg() = -3
Func ListFiles_ToTreeView($sSourceFolder, $hItem)
Local $sFile
; Force a trailing \
If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\"
; Start the search
Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*")
; If no files found then return
If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<
; Now run through the contents of the folder
While 1
; Get next match
$sFile = FileFindNextFile($hSearch)
; If no more files then close search handle and return
If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<
; Check if a folder
If @extended Then
; If so then call the function recursively
ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile))
Else
; If a file than write path and name
_GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)
EndIf
WEnd
; Close search handle
FileClose($hSearch)
EndFunc ;==>ListFiles_ToTreeView
So i am searching for the exact same function just with
GUICtrlCreateTreeViewItem
instead of
_GUICtrlTreeView_AddChild
Ps: i have a folder structure where i like to color each item green if a file only exist once and red if it exist more than once.
Could someone help?
Solution:

Hi Community,
I have a problem with the usage of _GUICtrlTreeView_AddChild and setting different item text colors (and different background colors), separately for the TreeView levels.
I use the UDF GUITreeViewEx.au3 of 'Melba23' and I renamed the functions to increase my understanding about the content. I already talked to him about his UDF to respect his rights and intellectual property. I read many forum threads, I tried many ways to get it, but it's seems to be impossible in the way that I use the UDF. Question:
How can I set different item text colors, separately for the TreeView levels?
How can I set different item background colors, separately for the TreeView levels?
I found out that _GUICtrlTreeView_AddChild don't let my set this properties directly. But after loading the TreeView content I can't change the items (children) too. Only the font weight to bold I could set with _GUICtrlTreeView_SetBold but I want to do this in a generic way directly at the creation (loading) of the TreeView.
Of course I tried the different functions to set text color or bkgColor, but it didn't work - maybe I do it wrong.
I really hope you can help me, give me a hint and understand what I want to do.
[Solved] final solution made by @LarsJ (see below) Thanks for your help - I'm grateful!
Sven
CODE
BEFORE
AFTER
ExecutionPlan.zip

Hello,
I am struggling in merging GUITreeViewEx, Shelltristate and enhancing to handle a third state that means : some items under are selected.
I have difficulties handling expand order and key Space (especially when node is collapsed).
Here the zip with UDF and and example.
The problem I might need some advice to handle :
1- When load Treeview, have a correct settings of the checkbox for a tristate tree
2 - Handle keyboard used for walking in tree
Chicken is checked and Steak is unchecked
When walking with arrow to Meat, it gets unchecked
3 - When node is collapsed and checked thru keyboard (space)
the middle state is possible which should not
Here is joined an animated gif showing the 3 problems
Thanks for your advices
GUITreeview3Ex.zip

Hi everyone. Im creating a GUI for an application. Im usinga treeview item and i want to add some information to the side of the treeview based on what cilditem you are pressing. For the moment i have a "get info" button that works. But that means that you have to select your child in the treeview, and then press a button to gte the info. I want the info to be visable as soon as you select it.
With uther controls you can just add it to the loop but it doesnt seem to work with tyhe UDF version of the treeview control. Is there anything I can do?
#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
;~ Create GUI
dim $guilabel[7]
local $currentlevel = 1
Local $hGui = GUICreate( "Grejs", 1000, 500, 600, 300, BitOR( $GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX ) )
Local $iBorderWidth = 4, $aPos = WinGetClientSize( $hGui )
$idTV = _GUICtrlTreeView_Create($hGui, $iBorderWidth, $iBorderWidth, $aPos[0]-2*$iBorderWidth-400, $aPos[1]-2*$iBorderWidth-30 )
$root_level = _GUICtrlTreeView_Add($idTV,0,"Root")
$item1 = _GUICtrlTreeView_AddChild($idTV, $root_level, "child1")
$item2 = _GUICtrlTreeView_AddChild($idTV, $root_level, "child2")
$item3 = _GUICtrlTreeView_AddChild($idTV, $root_level, "child3")
;~ Start Gui
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idTV
MsgBox(0,"","")
EndSwitch
WEnd
GUIDelete($hGui)
Exit
In this example, i want the msgbox to appear whenevr i select something in the treeview. It ios not my full code, but its an example of the problam i have. Help is much appritiated
/G

I can't explain easily what i want to do, so i made a picture:
What i want to do is to specify a treeview item, and then be able to move it right to be a child of the previous item, or left to do the opposite (make a child into a sibling). I also want to move and child items of the target with it, like in the bottom half of the above image depicts. However I didn't see any functions in the help file to move items around. All i want is a button that when pressed, makes the selected item and any of selected item's children move one layer to the right / left. Does anyone know how?
Edit: something along the lines of _GUICtrlTreeView_Level but SET level

This UDF can be used to make a Treeview and/or Listview able to browse Files. If you like it, please leave me a comment, also if you have any suggestions to make it better or if you found bugs.
FileExplorerTreeAndListview_source.zip

I started with a really good TreeView example from this forum and I'm incorporating it into my program. I've run into a problem correctly creating the items in the tree. I've tried several loops to achieve the desired outcome without success. I've attached a zip file containing the .au3 files and images of the incorrect/correct output.
The Data array in the script is just for testing. The Treeview items need to be created dynamically.
Thanks in advance for the help
TreeviewEX1.zip

Hi,
I recently discovered the "neoSearch" program ( '?do=embed' frameborder='0' data-embedContent>> ) and I saw it's GUI Design that is very beautyful, and I want to make a listing control like his ( I screenshoted to observe it's design ) : as you can see, that list, enlists many files and folders, but in a spaced beautyful way. How can I do that in autoit ?? He coded it in AUtoit but I can't find a dime on how to reach this design
EDIT: And yes, I searched in his old posted source code, and can't determine how he managed to create that list !! Can't find any GUICtrlCreateList function. I also searched for the control's coordinates resulted by the Window Tool, but incredibly don't exist in that source code !

Hi there
I am getting a strange issue occuring with treeview.
The below code creates a three level treeview. Each top level item has subitems, so all the top level items should have a "+" before them, allowing them to be expanded.
However, what is happening is that the last top level item is not showing a plus sign, until it is clicked once - then the plus sign appears.
Does anyone have an idea as to why this is happening?
Func _Populate_System_Treeview()
local $iNumberSystems,$iCount,$iFields,$tempRecord,$tv1,$tv2,$tv3
$sSQL="Select * from tbl_systems;"
If Not _EzMYSql_Query($sSQL) Then
MsgBox(0, "Query Error", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg())
EndIf
$iNumberSystems = _EzMySql_Rows() ; Number of systems (rows) in the table
global $tvi[$iNumberSystems][5]
for $iCount = 0 to $iNumberSystems-1 ; for each row in the table
$tempRecord = _EzMySql_FetchData() ; Read the row into a temporary var
for $iFields = 0 to 3
$tvi[$iCount][$iFields]=$tempRecord[$iFields] ; Fourth field reserved for pointer to treeviewbox items
Next
Next
_ArraySort($tvi,0,0,0,0)
for $iCount = 0 to $iNumberSystems-1
Switch $tvi[$iCount][2] ; SYS_level field
Case 1 ; Top level
$tv1=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $treeview) ; Display the item
$tvi[$iCount][4]=$tv1
Case 2 ; Second level
$tv2=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv1)
$tvi[$iCount][4]=$tv2
Case 3 ; THird level
$tv3=GUICtrlCreateTreeViewItem($tvi[$iCount][1], $tv2)
$tvi[$iCount][4]=$tv3
Case Else ; Should never happen
; msgbox(0,"Warning","Undefined system level detected")
EndSwitch
Next
EndFunc

Looking to build a TreeView dynamically from an Array (Array built from excel sheet)
Have not made the excel sheet yet, so I'm open to suggestions on layout so as to make it easiest as possible to get it into a treeview.
Thinking each row could be a item to add with the columns defining the placement in the trees, Like:
Cells(1,1) = "Level 1 Parent Name"
Cells(1,2) = "Level 2 Parent Name"
Cells(1,3) = "Level 3 Parent Name"
Cells(1,4) = "Add this item"
Cells(1,5) = ""
When value = "" then
Create entire branch or any part of it that doesn't already exist.
advance to next row
For processing speed I'd probably want to work with an array, like:
$aExcelData = _ExcelReadSheetToArray($oExcel,2,1,$LastUsedRow,$LastUsedCol)
Can someone help me with the loop? or maybe point to tool that may do this?

I need to take control of printer option selections in a treeview, and make selections. It works fine in XP, windows 2008, vista, windows 7. But not under windows 8 64 bits.
Here is what I've tried.
First, to bring up the window with the treeview,
1- start Notepad.
2- Press ctrl P to bring up the print dialog.
3- Select the "Microsoft XPS Document Writer" printer. I need to make this work on other printers, but this one is a good example, and should be present on any machine.
4- click on the Preferences button. This displays the Printing Preferences dialog.
5- click on Advanced.... This displays the "Microsoft XPS Document Writer v4 Advanced Options" dialog. In has a treeview. It is viewed by the autoit window tool as a SysTreeView32 class instance.
Coding attempts: Local $hwndTV = ControlGetHandle("Microsoft XPS Document Writer v4 Advanced Options", "", "[Class:SysTreeView32; INSTANCE=1]") ; this succeeds and populates $hndTV
; try to find the root node
Local $ItemHnd = _GuiCtrlTreeView_FindItemEx($hwndTV, "Microsoft XPS Document Writer v4 Advanced Document Settings") ; this fails and returns a "0" handle
; try to get the handle of the first item
Local $FirstItemHnd = _GuiCtrlTreeView_GetFirstItem($hwndTV) ; this succeeds
; try to get the text of the first item
msgbox(0,"","_GUICtrlTreeView_GetText($hwndTV, $hStart) ; this fails and returns an empty string, so that I can't step through entries looking for text
; try to use ControlTreeView Commands
msgbox(0,"",ControltreeView("Microsoft XPS Document Writer v4 Advanced Options", "", "[Class:SysTreeView32; INSTANCE=1]", "Exists", "#0") ; this returns 1: it can see the root node
;check if it sees children of the root node
msgbox(0,"",ControltreeView("Microsoft XPS Document Writer v4 Advanced Options", "", "[Class:SysTreeView32; INSTANCE=1]", "Exists", "#0|#0") ; this returns 0: it only sees a root node. This means that I can't navigate and find nodes, much less select them and make selections.
I would appreciate other ideas to make those selections using AutoIT.
Thanks!

I added tristate to the UDF TV Explorer, but is not working right, it does not select any subfolders ... and i'm having trouble with some functions also as: MyCtrlSetItemState() MyCtrlGetItemState() CheckChildItems() *I think the problem of the tristate is here* CheckParents() *or here* TV Explorer here: and functions used to add a tristate came of this topic: Video of the problem: https://dl.dropbox.com/u/58055873/Tv%20Explorer%20Treeview.wmv the result are atacched! Can someone try to fix please? thanks and sorry for my bad English! TVExplorer Tristate.rar