Jump to content
Sign in to follow this  
AwAke

A question regarding GUICtrlListViewItem and sorting of its contents. =]

Recommended Posts

AwAke

After posting my problem 3 days ago and I have had a few replies which has

pointed me in the direction in which I need to go. However the thread is now dead

and im still stuck on the problem I need solving. I would like it if the tab were clicked it would

sort it in order of size.

What I have atm is;

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#Include <Array.au3>
#include <GuiListView.au3>
Global $gui = GUICreate("test", 370, 130, 500, 500, -1)
GUISetState(@SW_SHOW)
$Filesize = GUICtrlCreateButton("File Size", 313, 10)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Filesize
        _fileSize()
        GUISetState(@SW_ENABLE, $gui)
        GUISetState(@SW_RESTORE, $gui)
       
        Case $msg = $GUI_EVENT_CLOSE
             ExitLoop
        EndSelect
Wend

Func _fileSize()
    GUISetState(@SW_DISABLE, $gui)
    Local $button, $item1, $item2, $item3, $input1, $msg, $size, $hListView
    Local $listview
    Local $child = GUICreate("test", 220, 250, 100, 200, -1, -1, $gui)
    Local $hlistview = GUICtrlCreateListView("File Name | Size", 10, 10, 200, 200);,$LVS_SORTDESCENDING)
    _GUICtrlListView_RegisterSortCallBack($hlistview)
    Local $go = GuiCtrlCreateButton("Search", 50, 218)
    Local $close = GuiCtrlCreateButton("Close", 130, 218)
    GUISetState()
    Global $hWnd, $iMsg, $iwParam, $ilParam
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $iCol
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    Global $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Global $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Global $iCode = DllStructGetData($tNMHDR, "Code")
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $go
                $search = FileFindFirstFile(@ProgramFilesDir & "\*.*")
                If $search = -1 Then
                    MsgBox(0, "Error", "No files/directories matched the search pattern")
                    ExitLoop
                EndIf

                Local $avArray[1]
                Local $asArray[1]
                Local $Array[1]

            While 1
                $file = FileFindNextFile($search)
                $path = @ProgramFilesDir & "\" & $file
                If @error Then ExitLoop
                $size = DirGetSize($path)
                $size = Round($size/1024/1024)
                _ArrayAdd($asArray, $file)
                _ArrayAdd($avArray, $size)
                $item1 = GUICtrlCreateListViewItem($file &"|"&$size& "MB's", $hlistview)
            WEnd
            FileClose($search)

        Case $msg = $hlistview
            $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
            $iCol = _GUICtrlListView_GetColumnCount($hListView)
            Dim $B_DESCENDING[$iCol]
            For $i = 0 To $iCol - 1
                $B_DESCENDING[$i] = True ; false = ascending, true = descending
            Next
            _GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
             
        Case $msg = $close
            GUIDelete($child)
            ExitLoop
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete($child)
            ExitLoop
           
        EndSelect
    Wend
EndFunc  ;==>Example

Sorry for the continous annoyance.

Thx in advance.

Edited by AwAke

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  

×