Sign in to follow this  
Followers 0
Wb-FreeKill

Listview and Browsing

2 posts in this topic

#1 ·  Posted (edited)

Okay i want to create a listview like when you browse in regedit.. it have to show all files and foldes..

Like this:

C:\

---Programes

------Myprogram

E:\

---Movies

------MyMovie

What is the best and fastets way of doing this.. maybe i could use this in some kind of way be splitting the resault and create listview items by that?

#Include <GUIConstants.au3>

GUICreate("BrowseDemo",400,400)

$TreeView = GUICtrlCreateTreeView(20,20,200,300)


$a = _FileSearch("C:\games\","*.*",1)
Msgbox(0,"File:",$a[1])


GUISetState()
While 1
    $msg = GUIGetmsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
    
WEnd    


Func _FileSearch($szRoot,$szMask,$nOption)
    $hFile = 0
    $szBuffer = ""
    $szReturn = ""
    $szPathList = "*"
    Dim $aNULL[1]

    If Not StringInStr($szMask,"\") Then
        $szRoot = $szRoot
    Else
         While StringInStr($szMask,"\")
              $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\"))
              $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\"))
         Wend
    EndIf
    If $nOption = 0 Then
         _FileSearchUtil($szRoot, $szMask, $szReturn)
    Else
         While 1
         sleep(10)             
             $hFile = FileFindFirstFile($szRoot & "*.*")
              If $hFile >= 0 Then
                   $szBuffer = FileFindNextFile($hFile)
                   While Not @ERROR
                        If $szBuffer <> "." And $szBuffer <> ".." And _
                             StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _
                             $szPathList = $szPathList & $szRoot & $szBuffer & "*"
                        $szBuffer = FileFindNextFile($hFile)
                   Wend
                   FileClose($hFile)
              EndIf
              _FileSearchUtil($szRoot, $szMask, $szReturn)
              If $szPathList == "*" Then ExitLoop
              $szPathList = StringTrimLeft($szPathList,1)
              $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"
              $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)
         Wend
    EndIf
    If $szReturn = "" Then
         $aNULL[0] = 0
         Return $aNULL
    Else
         Return StringSplit(StringTrimRight($szReturn,1),"*")
    EndIf
EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)
    $hFile = FileFindFirstFile($ROOT & $MASK)
    If $hFile >= 0 Then
         $szBuffer = FileFindNextFile($hFile)
         While Not @ERROR
              If $szBuffer <> "." And $szBuffer <> ".." Then _
                   $RETURN = $RETURN & $ROOT & $szBuffer & "*"
              $szBuffer = FileFindNextFile($hFile)
         Wend
         FileClose($hFile)
    EndIf
EndFunc
Edited by Wb-FreeKill

Share this post


Link to post
Share on other sites



This is what ive made so far, i cant get it to add all subfolders..

Anyone brainie who know what to do? :(

#Include <GUIConstants.au3>

GUICreate("BrowseDemo",400,400)

$TreeView = GUICtrlCreateTreeView(20,20,200,300)

$HDDrives = DrivegetDrive("FIXED")
For $i = 1 To $HDDrives[0]
    Search($HDDrives[$i] & "\","*.*")
Next    


GUISetState()

While 1
    $msg = GUIGetmsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
    
WEnd    



Func Search($SearchPath,$FileType)
$Item1 = GUICtrlCreateTreeViewItem(StringUpper($SearchPath),$TreeView)
$Search = FileFindFirstFile($SearchPath & $FileType)  
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

$Count = 1
DIM $SubTree[20]
DIM $SubTree1[999]
While 1
    $File = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    $Attrib = FileGetAttrib($SearchPath & $File)
    If StringInStr($Attrib,"D") Then
        $SubTree[$Count] = GUICtrlCreateTreeViewItem($Count & $File,$Item1)
        $Count = $Count +1
    EndIf
WEnd

FileClose($Search)
EndFunc

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
Sign in to follow this  
Followers 0