Hier mal ein Bsp. für SimpleSort per Spaltenklick.
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
$gui = GUICreate('Test LV-Sort')
$hListView = GUICtrlCreateListView('Spalte 1|Spalte 2', 10, 10, 300, 200)
For $i = 1 To 15
GUICtrlCreateListViewItem(Chr(Random(65,90)) & '|' & Chr(Random(65,90)), $hListView)
Next
GUISetState()
Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hListView)]
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
[/autoit] [autoit][/autoit] [autoit]Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
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 ; A column was clicked
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
_GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Edit:
Und hier mit _GUICtrlListView_RegisterSortCallBack:
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
$gui = GUICreate('Test LV-Sort')
$hListView = GUICtrlCreateListView('Spalte 1|Spalte 2', 10, 10, 300, 200)
For $i = 1 To 15
GUICtrlCreateListViewItem(Chr(Random(65,90)) & '|' & Chr(Random(65,90)), $hListView)
Next
$hListView = GUICtrlGetHandle($hListView)
$b1 = GUICtrlCreateButton('sort 1', 20, 240, 65, 20)
$b2 = GUICtrlCreateButton('sort 2', 100, 240, 65, 20)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]_GUICtrlListView_RegisterSortCallBack($hListView)
[/autoit] [autoit][/autoit] [autoit]Do
$msg = GUIGetMsg()
Switch $msg
Case $b1
_GUICtrlListView_SortItems($hListView, 0)
Case $b2
_GUICtrlListView_SortItems($hListView, 1)
EndSwitch
Until $msg = $GUI_EVENT_CLOSE
_GUICtrlListView_UnRegisterSortCallBack($hListView)