Jump to content

ShellTreeView


rasim
 Share

Recommended Posts

Hi Kafu,

after many hours and a lot of attempts, I surrender me. :)

The function returns an array of selected folders. Manually add the folders after the array is created (Quick, dirty, will only work for your language (have to admit that my Italian is rusty at most o:) ))

I also accept the dirtiest solution ! I don't understand in that point to modify your function. Could you introduce a small example? :)

- If I'm correct, the folders are all either accessible via AU macros or are sub-folders of those

@AppDataDir

@DesktopDir

@MyDocumentsDir

I apologize me not to have written it in my previous post: the main scope of my backup utility it's to be run from a emergency CD (build with BartPE) for any not functionally PCs. So, I can't know in advance what folders I found under "Documents and Settings".

This code in my Select Case statement open the folder but I have failed all the attempts to populate the tree:

Select
    
                        Case $sText = "Documents and Settings"
                            _GUICtrlTreeView_SetState($hTreeView, $hItem, BitOr($TVIS_EXPANDED, $TVS_CHECKBOXES) ,true)

;                            Case $sText = "Desktop"
;                                   MyCtrlSetItemState($hTreeView, $hItem, $GUI_CHECKED
                            
                    EndSelect

Best regards,

xavier66

Link to comment
Share on other sites

  • 1 month later...

Then I just say thanks to MrCreatoR for inspiring rasim for inspiring me, too :)...

Damn, this code is a bugger, too much traps to evade and corners to think around. Here's my latest (and sadly I'm sure not my last) version of the code. Any feedback's welcome :lmao:...

Best Regards

This is very close to what I was looking for. Could you modify it to show files as well? I tried but there are 3 main issues I have. First the files icons are all screwed up. Second the files and folders are not in order correctly. I have files above folders and stuff. :think: Third when I get the info returned the files have a trailing backslash.

Here is what I changed in _GetFolders:

Func _GetFolders($hWndTreeView, $hControl, $sDrive, $bInitTree)
        $hSearch = FileFindFirstFile($sDrive & "\*.*")
        While Not @error; first file found
            $sFiles = FileFindNextFile($hSearch) 
            If @error Then ExitLoop; next file found
            $sAttrib = FileGetAttrib($sDrive & $sFiles)
            If StringInStr($sAttrib, "D") Then
                $iSubChild = _GUICtrlTreeView_AddChild($hWndTreeView, $hControl, $sFiles, 3, 5)
            Else
                $iSubChild = _GUICtrlTreeView_AddChild($hWndTreeView, $hControl, $sFiles, 13, 15)
            EndIf
                if MyCtrlGetItemState($hWndTreeView, $hControl) <> 4 then MyCtrlSetItemState($hWndTreeView, $iSubChild, MyCtrlGetItemState($hWndTreeView, $hControl))
                if $bInitTree = false then
                    $hSearchSub = FileFindFirstFile($sDrive & $sFiles & "\*.*")
                    While Not @error; first subfile found
                        $sFilesSub = FileFindNextFile($hSearchSub) 
                        If @error Then ExitLoop; next file found
                        $sAttrib = FileGetAttrib($sDrive & $sFiles & "\" & $sFilesSub)
                        If StringInStr($sAttrib, "D") Then
                            $iSubChildsub = _GUICtrlTreeView_AddChild($hWndTreeView, $iSubChild, $sFilesSub, 3, 5)
                        Else
                            $iSubChildsub = _GUICtrlTreeView_AddChild($hWndTreeView, $iSubChild, $sFilesSub, 13, 15)
                        EndIf
                            if MyCtrlGetItemState($hWndTreeView, $iSubChild) <> 4 then MyCtrlSetItemState($hWndTreeView, $iSubChildsub, MyCtrlGetItemState($hWndTreeView, $iSubChild))
;~                      endif
                    WEnd
                    FileClose($hSearchSub)
                endif
;~          EndIf
        WEnd
        FileClose($hSearch)
EndFunc

Very messy... I know.

Link to comment
Share on other sites

I skipped the development of this func as a standalone product.

See SMF source for an enhanced version of this one (current version is SMF_ShellTristateTreeView_v15.au3). Don't remember and can't count the changes and tweaks I did to that code :think:. One thing I remember (cause I did it just some days ago :lmao:) is that I rewrote the part where it creates the tree to first read the files to an array and then sort the array afterwards (dir's with '_' and other special characters were sorted after the a-z characters, where as Windows puts them in front).

Obtaining the file icon's is also quiet difficult :), to get you started read these posts:

#493805

#577401

#578091

Last part should be easy, do something like:

$string = 'c:\\\testdir\\test\testfile.txt\'
while 1 ; to ensure that there are not double \ in string
    $string = StringReplace($string,'\\','\')
    if @extended = 0 then ExitLoop
wend
if stringright($string,1) = '\' then $string = stringleft($string,stringlen($string)-1)
MsgBox(0,'',$string)
Edited by KaFu
Link to comment
Share on other sites

Well I finally got it working with files. :) I also removed the trailing backslash from the returned strings. Now i just need to either figure out how to get the correct icon information or just live with having all of the files use a default icon. Once I finish I'll try posting the finished code here. My code may be sloppy though... cause I don't allways follow the same guidlines. lol. But maybe you'll be able to clean the code up a bit to release it as a udf. Cause I think it would be a great UDF to add to autoit. :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...