#include <GuiListView.au3>
Local $Str = _
'1998.aclo05.720p.mkv' & @CRLF & _
'2004.bhjh20.1080p.mkv' & @CRLF & _
'2004.cdfx02.720p.mkv' & @CRLF & _
'2004.ffin07.720p.mkv' & @CRLF & _
'2003.fwvs13.720p.mkv' & @CRLF & _
'2004.gxwn10.480p.mkv' & @CRLF & _
'2004.hszh14.1080p.mkv' & @CRLF & _
'2004.iolc08.720p.mkv' & @CRLF & _
'2004.jfwz15.720p.mkv' & @CRLF & _
'2002.jxli24.720p.mkv' & @CRLF & _
'2004.kazu04.720p.mkv' & @CRLF & _
'2004.kyrz03.1080p.mkv' & @CRLF & _
'2004.lpbr12.720p.mkv' & @CRLF & _
'2004.oujg19.720p.mkv' & @CRLF & _
'2002.ppmz17.720p.mkv' & @CRLF & _
'2004.qcfp09.720p.mkv' & @CRLF & _
'2004.qwqm16.480p.mkv' & @CRLF & _
'2004.rcvj25.720p.mkv' & @CRLF & _
'2010.rrnd21.720p.mkv' & @CRLF & _
'2012.scsf23.720p.mkv' & @CRLF & _
'2004.usvm06.720p.mkv' & @CRLF & _
'2009.wwhv01.720p.mkv' & @CRLF & _
'2008.xbgt18.720p.mkv' & @CRLF & _
'2004.xzlv22.720p.mkv' & @CRLF & _
'2004.youh11.720p.mkv'
Local $aSR1 = StringRegExp($str, '\d+(?=\.\d+p)', 3)
Local $aSR2 = StringRegExp($str, '\V+', 3)
GUICreate('ListView 排序', 300, 400)
$hListView = GUICtrlCreateListView('集别|文件名', 2, 2, 296, 380)
GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
For $i = 0 To UBound($aSR1) - 1
GUICtrlCreateListViewItem($aSR1[$i] & '|' & $aSR2[$i], $hListView)
Next
_GUICtrlListView_SetColumnWidth($hListView, 0, 65)
GUIRegisterMsg(0x004E, 'WM_NOTIFY')
_GUICtrlListView_RegisterSortCallBack($hListView)
_GUICtrlListView_SortItems($hListView, 0)
GUISetState()
Do
Until GUIGetMsg() = -3
_GUICtrlListView_UnRegisterSortCallBack($hListView)
GUIDelete()
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
$iIDFrom = DllStructGetData($tNMHDR, 'IDFrom')
$iCode = DllStructGetData($tNMHDR, 'Code')
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
If DllStructGetData($tInfo, 'SubItem') = 0 Then
_GUICtrlListView_SortItems($hListView, 0)
EndIf
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY
|