xtcislove Posted August 26, 2018 Share Posted August 26, 2018 (edited) 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. Edited August 26, 2018 by xtcislove Link to comment Share on other sites More sharing options...
AutoBert Posted August 26, 2018 Share Posted August 26, 2018 (edited) The color change for file and folders is the same, just use GUICtrlSetBkColor. Here the script a little enhanced: expandcollapse popup;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <ColorConstants.au3> ;Global $sPath = @ScriptDir Global $sPath = StringRegExpReplace(@AutoItExe, '(.+\\).+', '$1') ; <- als Beispiel das AutoIt-Verzeichnis Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() ToolTip('Verzeichnis wird eingelesen. Bitte warten!', Default, Default, 'TreeView-Example', $TIP_INFOICON, $TIP_BALLOON) _GUICtrlTreeView_BeginUpdate($idTreeView) _CreatePath($sPath, $idTreeView) _GUICtrlTreeView_EndUpdate($idTreeView) ToolTip('') 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) If $aFolder[$i] = 'Scite' Then GUICtrlSetBkColor(-1, $COLOR_RED) Else GUICtrlSetBkColor(-1, $COLOR_Yellow) EndIf _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) If StringInStr($aFiles[$i], 'Readme') Then GUICtrlSetBkColor(-1, $COLOR_RED) Else GUICtrlSetBkColor(-1, $COLOR_Yellow) EndIf Next EndFunc ;==>_CreatePath it's only demostration (playing). If you want to know how to build the logic, than i must ask: What's a duplicate file? Same name Same size Same hash Files with same name and size can be different, files with same hash most are real duplicates. So i suggest try following example(s) in help: _GUICtrlListView_SetItemParam _Crypt_HashFile these will help to build a stable logic. Edited August 26, 2018 by AutoBert Link to comment Share on other sites More sharing options...
xtcislove Posted August 26, 2018 Author Share Posted August 26, 2018 (edited) @AutoBert I like to check only by name. The path structures and filenames are unique. If a file is in Folder 1 and Folder 2 its in the same sub directorys. Folder structure: (Edit: Colored for desired result) Spoiler ;-> This is the folder i build my TreeView from. Folder\ Folder 1\ Folder 2\ Folder 3\ ;-< This is the folder i build my TreeView from. Folder 1\ characters\models\geralt\head\model\eye__geralt_d01.xbm characters\models\geralt\head\model\h_01_mg__geralt_d01.xbm characters\models\geralt\head\model\h_01_mg__geralt_d02.xbm characters\models\geralt\head\model\h_01_mg__geralt_n01.xbm characters\models\geralt\head\model\h_01_mg__geralt_n02.xbm characters\models\geralt\head\model\h_01_mg__geralt_tattoo_d01.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d01_mark.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d01_mark_tattoo.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d02_mark.xbm characters\models\geralt\body\model\body_01_mg__geralt_d01.xbmFolder 2\ characters\models\geralt\head\model\eye__geralt_d01.xbm characters\models\geralt\head\model\h_01_mg__geralt_d01.xbm characters\models\geralt\head\model\h_01_mg__geralt_d02.xbm characters\models\geralt\head\model\h_01_mg__geralt_n01.xbm characters\models\geralt\head\model\h_01_mg__geralt_n02.xbm characters\models\geralt\head\model\h_01_mg__geralt_tattoo_d01.xbm characters\models\geralt\head\model\h_01_mg__geralt_tattoo_d02.xbm characters\models\geralt\head\model\h_02_mg__geralt_d01.xbm characters\models\geralt\head\model\h_02_mg__geralt_n01.xbm characters\models\geralt\head\model\h_03_mg__geralt_d01.xbm characters\models\geralt\head\model\h_03_mg__geralt_n01.xbm characters\models\geralt\head\model\h_04_mg__geralt_d01.xbm characters\models\geralt\head\model\h_04_mg__geralt_n01.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d01_mark.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d01_mark_tattoo.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d02_mark.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_d02_mark_tattoo.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_n01_mark.xbm characters\models\geralt\head\model\ep1_mark\h_01_mg__geralt_n02_mark.xbm characters\models\geralt\body\model\body_01_mg__geralt_d01.xbm characters\models\geralt\body\model\s_01_mg__body_hires_d01.xbmFolder 3\ dlc\dlc6\data\characters\models\main_npc\triss\model\body_01_wa__triss_dlc_d01.xbm dlc\dlc6\data\characters\models\main_npc\triss\model\body_01_wa__triss_dlc_s01.xbm dlc\dlc4\data\characters\models\main_npc\yennefer\model\body_05_wa__yennefer_d01.xbm dlc\dlc4\data\characters\models\main_npc\yennefer\model\body_05_wa__yennefer_d02.xbm dlc\dlc4\data\characters\models\main_npc\yennefer\model\glove_01_wa__yennefer_d01.xbm dlc\dlc4\data\characters\models\main_npc\yennefer\model\scarf_01_wa__yennefer_d01.xbm dlc\dlc4\data\characters\models\main_npc\yennefer\model\stockings_01_wa__yennefer_d01.xbm dlc\dlc4\data\characters\models\main_npc\yennefer\model\yennefer_feathers_d01.xbm dlc\dlc11\data\characters\models\main_npc\ciri\model\body_01_wa__ciri_dlc_d01.xbm dlc\dlc11\data\characters\models\main_npc\ciri\model\body_01_wa__ciri_dlc_d02.xbm dlc\dlc11\data\characters\models\main_npc\ciri\model\body_01_wa__ciri_dlc_d03.xbm dlc\dlc11\data\characters\models\main_npc\ciri\model\body_01_wa__ciri_dlc_s01.xbm dlc\dlc11\data\characters\models\main_npc\ciri\model\ciri_chainmail_dlc_d01.xbm dlc\dlc11\data\characters\models\main_npc\ciri\model\ciri_chainmail_dlc_n01.xbm characters\models\main_npc\yennefer\model\body_01_wa__yennefer.w2mesh characters\models\main_npc\yennefer\model\body_01_wa__yennefer.w2mesh.1.buffer characters\models\main_npc\yennefer\model\body_01_wa__yennefer_a01.xbm characters\models\main_npc\yennefer\model\body_01_wa__yennefer_a02.xbm characters\models\main_npc\yennefer\model\body_01_wa__yennefer_d01.xbm characters\models\main_npc\yennefer\model\body_01_wa__yennefer_d02.xbm characters\models\main_npc\yennefer\model\body_01_wa__yennefer_hooded.w2mesh characters\models\main_npc\yennefer\model\body_01_wa__yennefer_hooded.w2mesh.1.buffer characters\models\main_npc\yennefer\model\body_01_wa__yennefer_n01.xbm characters\models\main_npc\yennefer\model\body_01_wa__yennefer_n02.xbm characters\models\main_npc\yennefer\model\dress_01_wa__yennefer_a01.xbm characters\models\main_npc\yennefer\model\dress_01_wa__yennefer_a02.xbm characters\models\main_npc\yennefer\model\dress_01_wa__yennefer_d01.xbm characters\models\main_npc\yennefer\model\dress_01_wa__yennefer_d02.xbm characters\models\main_npc\yennefer\model\dress_01_wa__yennefer_n01.xbm characters\models\main_npc\yennefer\model\dress_01_wa__yennefer_n02.xbm characters\models\main_npc\yennefer\model\fur_01_wa__yennefer.w2mesh characters\models\main_npc\yennefer\model\fur_01_wa__yennefer.w2mesh.1.buffer characters\models\main_npc\yennefer\model\fur_01_wa__yennefer_a01.xbm characters\models\main_npc\yennefer\model\fur_01_wa__yennefer_d01.xbm characters\models\main_npc\yennefer\model\fur_01_wa__yennefer_n01.xbm characters\models\main_npc\yennefer\model\fur_02_wa__yennefer.w2mesh characters\models\main_npc\yennefer\model\fur_02_wa__yennefer.w2mesh.1.buffer characters\models\main_npc\yennefer\model\fur_03_wa__yennefer.w2mesh characters\models\main_npc\yennefer\model\fur_03_wa__yennefer.w2mesh.1.buffer characters\models\main_npc\yennefer\model\l_01_wa__yennefer.w2mesh characters\models\main_npc\yennefer\model\l_01_wa__yennefer.w2mesh.1.buffer characters\models\main_npc\yennefer\model\l_02_wa__yennefer.w2mesh characters\models\main_npc\yennefer\model\l_02_wa__yennefer.w2mesh.1.buffer characters\models\main_npc\yennefer\model\l_02_wa__yennefer_a01.xbm characters\models\main_npc\yennefer\model\l_02_wa__yennefer_d01.xbm characters\models\main_npc\yennefer\model\l_02_wa__yennefer_n01.xbm characters\models\main_npc\yennefer\model\yennefer__body_d_notcensor.xbm characters\models\main_npc\yennefer\model\yennefer__body_n_notcensor.xbm characters\models\main_npc\yennefer\h_01_wa__yennefer\eye__yennefer_d01.xbm characters\models\main_npc\yennefer\h_01_wa__yennefer\h_01_wa__yennefer_a01.xbm characters\models\main_npc\yennefer\h_01_wa__yennefer\h_01_wa__yennefer_b01.xbm characters\models\main_npc\yennefer\h_01_wa__yennefer\h_01_wa__yennefer_d01.xbm characters\models\main_npc\yennefer\h_01_wa__yennefer\h_01_wa__yennefer_n01.xbm characters\models\main_npc\triss\model\body_01_wa__triss_d01.xbm characters\models\main_npc\triss\model\body_02_wa__triss_d01.xbm characters\models\main_npc\triss\model\body_02_wa__triss_s01.xbm characters\models\main_npc\triss\model\body_03_wa__triss.w2mesh characters\models\main_npc\triss\model\body_03_wa__triss.w2mesh.1.buffer characters\models\main_npc\triss\model\body_03_wa__triss_a01.xbm characters\models\main_npc\triss\model\body_03_wa__triss_d01.xbm characters\models\main_npc\triss\model\body_03_wa__triss_n01.xbm characters\models\main_npc\triss\model\body_03_wa__triss_s01.xbm characters\models\main_npc\triss\model\i_03_wa__triss_d01.xbm characters\models\main_npc\triss\h_01_wa__triss\h_01_wa__triss_b01.xbm characters\models\main_npc\triss\h_01_wa__triss\h_01_wa__triss_d01.xbm characters\models\main_npc\triss\h_01_wa__triss\h_01_wa__triss_d02.xbm characters\models\main_npc\triss\h_01_wa__triss\h_01_wa__triss_d03.xbm characters\models\main_npc\triss\h_01_wa__triss\h_01_wa__triss_n01.xbm characters\models\main_npc\ciri\model\body_01_wa__ciri_d01.xbm characters\models\main_npc\ciri\model\body_01_wa__ciri_d02.xbm characters\models\main_npc\ciri\model\body_01_wa__ciri_d03.xbm characters\models\main_npc\ciri\model\body_01_wa__ciri_s01.xbm characters\models\main_npc\ciri\model\body_01_wa__ciri_s03.xbm characters\models\main_npc\ciri\model\body_03__wa_ciri_a01.xbm characters\models\main_npc\ciri\model\body_03__wa_ciri_d01.xbm characters\models\main_npc\ciri\model\body_03__wa_ciri_n01.xbm characters\models\main_npc\ciri\model\body_05_wa__ciri_d01.xbm characters\models\main_npc\ciri\model\collar_01_wa__ciri_d01.xbm characters\models\main_npc\ciri\model\item_07_wa__ciri_d01.xbm characters\models\main_npc\ciri\model\item_10_wa__ciri_d01.xbm characters\models\main_npc\ciri\model\l_01_wa__lingerie_ciri.w2mesh characters\models\main_npc\ciri\model\l_01_wa__lingerie_ciri.w2mesh.1.buffer characters\models\main_npc\ciri\h_01_wa__ciri\eye__ciri_d01.xbm characters\models\main_npc\ciri\h_01_wa__ciri\eye__ciri_d02.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_a01.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_a02.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_a03.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_a04.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_b01.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_d01.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_d02.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_d03.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_d04.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_n01.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_n02.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_n03.xbm characters\models\main_npc\ciri\h_01_wa__ciri\h_01_wa__ciri_n04.xbm So i am able to check if a file is in more than one folder and color it red instead of green, but i dont know how to paint the sub directorys red, it is in. Edited August 26, 2018 by xtcislove Link to comment Share on other sites More sharing options...
xtcislove Posted August 27, 2018 Author Share Posted August 27, 2018 (edited) My function for finding duplicated files: Func _FindDuplicates($sPath) Local $aFolder, $aFiles, $aFind, $aRet $aFolder = _FileListToArrayRec($sPath, "*", 1, 1, 0, 1) $aFiles = _FileListToArrayRec($sPath, "*", 1, 1, 0, 0) For $i = 1 To $aFiles[0] $aFind = _ArrayFindAll($aFiles, $aFiles[$i]) If UBound($aFind) <> 1 Then $aRet &= $aFolder[$i] & "|" Next $aRet = StringSplit(StringTrimRight($aRet, 1), "|") Return $aRet EndFunc This will return all "trees" that need to be colored red. I could loop trough each line of this array and split each line by "\" but that would also color the characters folder red in Folder_3, too. I was thinking of using GUICtrlCreateDummy() or to handle each TreeView Item in a array and if the file is a duplicate i could loop trough GUICtrlCreateDummy() or the array, but that wouldnt work either, since the CreatePath function, loops torugh each folder and not the whole tree. Edited August 27, 2018 by xtcislove Link to comment Share on other sites More sharing options...
xtcislove Posted August 28, 2018 Author Share Posted August 28, 2018 So i found out how to build an array from every folder/file with its Handle: But i dont know how to use it and the structure is not quiet right. expandcollapse popupFunc _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] $aAllItem[0][0] += 1 ReDim $aAllItem[$aAllItem[0][0]+1][3] Local $sItemName = _StripPath($aFolder[$i]) $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) GUICtrlSetColor(-1, 0x098902) GUICtrlSetImage(-1, "shell32.dll", 4) $aAllItem[$aAllItem[0][0]][0] = $idItem $aAllItem[$aAllItem[0][0]][1] = $sItemName _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $aAllItem[0][0] += 1 ReDim $aAllItem[$aAllItem[0][0]+1][3] Local $sItemName = _StripPath($aFiles[$i]) $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) GUICtrlSetImage(-1, @ScriptDir & "\tools\icon.ico") GUICtrlSetColor(-1, 0x098902) $aAllItem[$aAllItem[0][0]][0] = $idItem $aAllItem[$aAllItem[0][0]][1] = $sItemName Next EndFunc Link to comment Share on other sites More sharing options...
LarsJ Posted September 3, 2018 Share Posted September 3, 2018 Have you made it work? It's not impossible. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
xtcislove Posted September 9, 2018 Author Share Posted September 9, 2018 On 3.9.2018 at 10:32 PM, LarsJ said: Have you made it work? It's not impossible. Yeah i made it, but not a good solution i think... expandcollapse popupFunc _FindDuplicates($sPath) Local $aFiles, $aFind, $aRet $aFiles = _FileListToArrayRec($sPath, "*", 1, 1, 0, 0) For $i = 1 To $aFiles[0] $aFind = _ArrayFindAll($aFiles, $aFiles[$i]) If UBound($aFind) <> 1 Then If Not StringInStr($aRet, $aFiles[$i]) Then $aRet &= $aFiles[$i] & "|" EndIf Next $aRet = StringSplit(StringTrimRight($aRet, 1), "|") Return $aRet EndFunc Func _CreateTreeView($sPath, $idParent, $aDupl) Local $aFolder, $aFiles, $idItem, $aPath 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) GUICtrlSetImage($idItem, "shell32.dll", 4) GUICtrlSetColor($idItem, 0x098902) $aPath = _FileListToArrayRec($sPath & $aFolder[$i], "*", 1, 1, 0, 0) If IsArray($aPath) Then For $s = 1 To $aPath[0] _ArraySearch($aDupl, $aPath[$s]) If Not @error Then GUICtrlSetColor($idItem, 0xf41e0e) Next EndIf _CreateTreeView($sPath & $aFolder[$i], $idItem, $aDupl) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) GUICtrlSetImage($idItem, @ScriptDir & "\tools\icon.ico") GUICtrlSetColor($idItem, 0x098902) _ArraySearch($aDupl, $aFiles[$i]) If Not @error Then GUICtrlSetColor($idItem, 0xf41e0e) Next EndFunc Link to comment Share on other sites More sharing options...
LarsJ Posted September 10, 2018 Share Posted September 10, 2018 (edited) This is a way it can be done. The treeview is created with your code from a previous post. A dictionary object is used to find file duplicates. In case of duplicates, ItemParam is set to the value 1 all way up through the treeview. In custom draw code, items with ItemParam = 1 are drawn with red background color. Otherwise green. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Global $hTreeView, $oDict = ObjCreate( "Scripting.Dictionary" ) Example() Func Example() ; Create GUI Local $hGui = GUICreate( "Demo1", 620, 420 ) ; Create TreeView $hTreeView = _GUICtrlTreeView_Create( $hGui, 10, 10, 600, 400, $TVS_HASBUTTONS+$TVS_HASLINES+$TVS_LINESATROOT+$TVS_DISABLEDRAGDROP+$TVS_SHOWSELALWAYS, $WS_EX_CLIENTEDGE ) ; WM_NOTIFY message handler GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Show GUI GUISetState() ; Fill TreeView _GUICtrlTreeView_BeginUpdate( $hTreeView ) ListFiles_ToTreeView( @ScriptDir & "\f", 0 ) _GUICtrlTreeView_EndUpdate( $hTreeView ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete() EndFunc Func ListFiles_ToTreeView( $sSourceFolder, $hItem ) ; 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 Local $sFile, $hFile 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 $hFile = _GUICtrlTreeView_AddChild( $hTreeView, $hItem, $sFile ) If $oDict.Exists( $sFile ) Then ; File exists in another folder ; Set second, third, ... files red While $hFile _GUICtrlTreeView_SetItemParam( $hTreeView, $hFile, 1 ) ; Red $hFile = _GUICtrlTreeView_GetParentHandle( $hTreeView, $hFile ) WEnd If $oDict( $sFile ) Then ; Set first file red $hFile = $oDict( $sFile ) While $hFile _GUICtrlTreeView_SetItemParam( $hTreeView, $hFile, 1 ) ; Red $hFile = _GUICtrlTreeView_GetParentHandle( $hTreeView, $hFile ) WEnd $oDict( $sFile ) = 0 ; Set first file red only once EndIf Else $oDict( $sFile ) = $hFile ; To be able to set first file red EndIf EndIf WEnd ; Close search handle FileClose( $hSearch ) EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Local $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Local $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hTreeView Switch $iCode Case $NM_CUSTOMDRAW Local $tNMTVCUSTOMDRAW = DllStructCreate( $tagNMTVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMTVCUSTOMDRAW, "DrawStage" ) Switch $dwDrawStage ; Specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Item-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Local $iItemParam = DllStructGetData( $tNMTVCUSTOMDRAW, "ItemParam" ) If $iItemParam Then DllStructSetData( $tNMTVCUSTOMDRAW, "ClrTextBk", 0xCCCCFF ) ; Red, BGR Else DllStructSetData( $tNMTVCUSTOMDRAW, "ClrTextBk", 0xCCFFCC ) ; Green EndIf Return $CDRF_NEWFONT ; Return $CDRF_NEWFONT after changing colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG #forceref $hWnd, $iMsg, $wParam EndFunc The zip-file contains the code and a simpel file/folder structure to test it. tv.7z Edited September 10, 2018 by LarsJ Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions 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