Jump to content
Sign in to follow this  
Wb-FreeKill

When do we see any TreeView stuff?

Recommended Posts

Tried getting in tuch with Holger by PM, but when do we see some treeview stuff like all the new Listview**** ?

Just wondering, i really need it :(

Share this post


Link to post
Share on other sites

What do you mean with "when do we see" ?  :(

It's already implemted ( long time ago)...

So long...

Holger

<{POST_SNAPBACK}>

Hmm, i mean lile _GUICtrlTreeViewGetItemText and so on.. i know your working on some Treeview browseing right?

Share this post


Link to post
Share on other sites

It was me supposed to be doing this sort of stuff.  Sorry.

<{POST_SNAPBACK}>

np, i just though someone was doing it at this moment... im asking because i have some problems with my script "TreeView Browsing", something i cannot do at this moment i think...

(Short explanation)

When using the FileFindFirstFile & FileFindNextFile to create a tree with folders of a harddrive, i would like to retrieve the path into an Input when browsing trough the tree.. i can't find ANY way to possibly do this!

Here's my script, hope you guy's know what im talking about!

#include <GUIConstants.au3>
#include <GuiListView.au3>
Const $LVS_SORTDESCENDING = 0x0020

GUICreate("Treeview Browsing - By FreeKill",750,500)
$MainTree = GUICtrlCreateTreeView(1, 60, 250, 417)
GUICtrlSetImage(-1,"shell32.dll",3,4)
GUICtrlSetImage(-1,"shell32.dll",4,2)
$SubTree = GUICtrlCreateListview("Name|Size|Type|Changed",258, 60, 492, 417)
_GUICtrlListViewSetColumnWidth($SubTree, 0,190)
_GUICtrlListViewSetColumnWidth($SubTree, 1,100)
_GUICtrlListViewSetColumnWidth($SubTree, 2,80)
_GUICtrlListViewSetColumnWidth($SubTree, 3,100)
_GUICtrlListViewJustifyColumn ($SubTree, 1, 1)
_GUICtrlListViewJustifyColumn ($SubTree, 3, 0)
GUICtrlCreateGroup("",0,53,252,425)

$DirInput = GUICtrlCreateInput("C:\Programmer\",5,10,183,20)
$BrowseBtn = GUICtrlCreateButton("Search",193,10,60,21)
$CurrentPath = GUICtrlCreateInput(GUICtrlRead($DirInput),5,35,247,20)
GUICtrlSetState(-1,$GUI_Disable)
$ObjCount = GUICtrlCreateInput("0 Object(s)",0,480,150,20,$ES_READONLY)
$SpaceCount = GUICtrlCreateInput("N/A",154,480,596,20,$ES_READONLY)
GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($SubTree)]
_LoadTree(GUICtrlRead($DirInput), $MainTree,0)


While 1;Main Loop
    $Msg = GUIGetMsg()
Select
    Case $Msg = $GUI_EVENT_CLOSE
        Exit

    Case $msg = $BrowseBtn 
        GUICtrlDelete($MainTree)
        $MainTree = GUICtrlCreateTreeView(1, 60, 250, 417)
        GUICtrlSetImage(-1,"shell32.dll",3,4)
        GUICtrlSetImage(-1,"shell32.dll",4,2)
        GUICtrlSetdata($CurrentPath,GUICtrlRead($DirInput))
        _LoadTree(GUICtrlRead($DirInput), $MainTree,0);Path/Tree/State
        SetColumnWidth()    
            
    Case $msg > 4
        _GUICtrlListViewDeleteAllItems($SubTree)
        $Read = GUICtrlread($MainTree,1)
        GUICtrlSetdata($CurrentPath,GUICtrlRead($DirInput) & $Read[0] & "\")
        _LoadTree(GUICtrlRead($DirInput) & $Read[0] & "\", $SubTree,1);Path/Tree/State
        GUICtrlSetdata($ObjCount,_GUICtrlListViewGetItemCount($SubTree) & " Object(s)")
        $TheSize = DirGetSize(GUICtrlRead($Currentpath)) / 1024 / 1024
        $FreeSpace = DriveSpaceFree(Stringleft(GUICtrlRead($DirInput),3))/ 1024
        GUICtrlSetdata($SpaceCount,Stringleft($TheSize,Stringinstr($TheSize,".")+2) & " MB (Free Space: "& StringLeft($FreeSpace,StringInStr($FreeSpace,".")+1) & " GB)")
        SortListViewSize($SubTree,1)
        SetColumnWidth()
    
    
    Case $msg = $SubTree AND GUICtrlGetState($SubTree) > 0 AND GUICtrlGetState($SubTree) < 4
        If GUICtrlGetState($SubTree) = 1 Then 
            SortListViewSize($SubTree,1)
        Else
            _GUICtrlListViewSort($SubTree, $B_DESCENDING, GUICtrlGetState($SubTree))
        EndIf
        SetColumnWidth()


EndSelect
Wend;Mainloop end

;                Functions
;////////////////////////////////////////////
Func _LoadTree($sRoot, $hParent, $GetFiles)
    Local $ThePath = GUICtrlRead($CurrentPath)
    Local $sMask = "*.*"
    Local $aFile[1], $nCnt = 1, $newParent
    Local $hSearch = FileFindFirstFile($sRoot & $sMask)
    If $hSearch >= 0 Then
       $sFile = FileFindNextFile($hSearch)
       While not @error
            ReDim $aFile[$nCnt]
            $aFile[$nCnt-1] = $sFile
            $nCnt = $nCnt + 1
            $sFile = FileFindNextFile($hSearch)
       Wend
       FileClose($hSearch)
    EndIf
    For $i = 0 To UBound($aFile) - 1
        If $aFile[$i] == "." or $aFile[$i] == ".." Then ContinueLoop
        If $GetFiles = 0 Then;Do not include files
            If StringInStr(FileGetAttrib($sRoot & "\" & $aFile[$i]), "D") Then
                $newParent = GUICtrlCreateTreeViewItem($aFile[$i], $hParent)
                _LoadTree($sRoot & $aFile[$i] & "\", $newParent,0);Keep search trough folders
                ContinueLoop
            Endif
        ElseIf $GetFiles = 1 Then;Include Files
            $FilegetSize = Round(FileGetSize($ThePath & $aFile[$i]) / 1024,0) 
            $Time = FileGetTime($ThePath & $aFile[$i], 1)
            If Not @Error Then
                $yyyymd = $Time[2] & "." & $Time[1] & "." & $Time[0] & " " & $Time[3] & ":" & $Time[4]
                If StringInStr(FileGetAttrib($sRoot & "\" & $aFile[$i]), "D") Then
                    $SnewParent = GUICtrlCreateListViewItem($aFile[$i] &"||"& _FileGetType($ThePath & $aFile[$i]) &"|"& $yyyymd, $hParent)
                    ContinueLoop
                Endif
                GUICtrlCreateListViewItem($aFile[$i] &"|"& $FilegetSize & " KB" &"|"& _FileGetType($ThePath & $aFile[$i]) &"|"& $yyyymd, $hParent);Include files
                GUICtrlSetImage(-1,"shell32.dll",3,4)
                GUICtrlSetImage(-1,"shell32.dll",4,2)
            EndIf
        EndIf
    Next
EndFunc


Func _FileGetExt($sFileName)
    Dim $DotPos, $Other
    $DotPos = StringInStr($sFileName, '.', 1, -1)
    If $DotPos = 0 Then Return ''
    $Other = StringInStr($sFileName, '\', 1, -1)
    If $Other > $DotPos Then Return ''
    $Other = StringInStr($sFileName, ':', 1, -1)
    If $Other > $DotPos Then Return ''
    Return StringTrimLeft($sFileName, $DotPos)
EndFunc
Func _FileGetType($sFileName)
    Dim $Type
    If StringInStr(FileGetAttrib($sFileName),"D") Then
        $Type = RegRead('HKEY_CLASSES_ROOT\Folder', '')
    Else
        Dim $Ext = _FileGetExt($sFileName)
        $Type = RegRead('HKEY_CLASSES_ROOT\.' & $Ext, '')
        If $Type = '' Then
            $Type = $Ext & '-file'
        Else
            Dim $Type2 = RegRead('HKEY_CLASSES_ROOT\' & $Type, '')
            If $Type2 <> '' Then $Type = $Type2
        EndIf
    EndIf
    Return $Type
EndFunc

Func SetColumnWidth()
    If _GUICtrlListViewGetColumnWidth($SubTree,0) <> 200 Then _GUICtrlListViewSetColumnWidth($SubTree,0,190)
    If _GUICtrlListViewGetColumnWidth($SubTree,1) <> 100 Then _GUICtrlListViewSetColumnWidth($SubTree,1,100)
    If _GUICtrlListViewGetColumnWidth($SubTree,2) <> 80 Then _GUICtrlListViewSetColumnWidth($SubTree,2,80)
    If _GUICtrlListViewGetColumnWidth($SubTree,3) <> 100 Then _GUICtrlListViewSetColumnWidth($SubTree,3,100)
EndFunc

Func SortListViewSize($hListView,$hColumn)
    Local $ItemsCount = _GUICtrlListViewGetItemCount($hListView) 
    If NOT $ItemsCount = 0 Then
        Dim $ColumnGetItemtext[$ItemsCount]
    ;Remove KB
        For $i = 0 To $ItemsCount -1 
            $ColumnGetItemtext = _GUICtrlListViewGetItemText($hListView,$i,$hColumn)
            If StringRight($ColumnGetItemtext,2) = "KB" Then 
                _GUICtrlListViewSetItemText ($hListView, $i, $hColumn, StringTrimRight($ColumnGetItemtext,3))
            Else
                ContinueLoop
            EndIf
        Next
    ;Sort Listview
        _GUICtrlListViewSort($hListView, $B_DESCENDING, $hColumn)
    ;Put KB
        For $i = 0 To $ItemsCount -1
            $ColumnGetItemtext = _GUICtrlListViewGetItemText($hListView,$i,$hColumn)
            If $ColumnGetItemtext = '' Then ContinueLoop
            _GUICtrlListViewSetItemText ($hListView, $i, $hColumn, $ColumnGetItemtext & " KB")
        Next
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

3.1.1.50 now has the GuiTreeView UDFs, I posted in Idea Lab, what I had so far and asked for any other suggestions, but no replies, so If any others are needed I'll see what I can do.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

3.1.1.50 now has the GuiTreeView UDFs, I posted in Idea Lab, what I had so far and asked for any other suggestions, but no replies, so If any others are needed I'll see what I can do.

<{POST_SNAPBACK}>

Great great, thank you!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...