exodius Posted July 9, 2008 Share Posted July 9, 2008 I've been looking at the examples for _GuiCtrlListView_SimpleSort and _GUICtrlListView_RegisterSortCallBack..._GUICtrlListView_SortItems... _GUICtrlListView_UnRegisterSortCallBack in the Help File, and I can't figure out how to modify either to do just a descending sort... The examples basically give behavior where you click a column once and it sorts it ascending, click it again and it sorts it descending, then ascending, and so on. I'm trying to figure out how to make it so each time you click a column it reorders the listview again based on that column in descending order. Any thoughts on how or if it's possible? Link to comment Share on other sites More sharing options...
picaxe Posted July 9, 2008 Share Posted July 9, 2008 (edited) Try this, modified from Autoit help file expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work Global $hListView, $B_DESCENDING _Main() Func _Main() GUICreate("ListView SimpleSort", 400, 300) $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268) GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("line4|5|a", $hListView) GUICtrlCreateListViewItem("line5|4|b", $hListView) GUICtrlCreateListViewItem("line6|3|c", $hListView) GUICtrlCreateListViewItem("line7|2|d", $hListView) GUICtrlCreateListViewItem("line8|1|e", $hListView) _GUICtrlListView_SetColumnWidth($hListView, 0, 75) _GUICtrlListView_SetColumnWidth($hListView, 1, 75) _GUICtrlListView_SetColumnWidth($hListView, 2, 75) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func WM_NOTIFY($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) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $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")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edited July 9, 2008 by picaxe Link to comment Share on other sites More sharing options...
exodius Posted July 9, 2008 Author Share Posted July 9, 2008 That's exactly what I was looking for! I know it basically says to do that in the syntax explanation, but it's not the most intuitive thing to know how to add to a script... Thank you sir! Link to comment Share on other sites More sharing options...
picaxe Posted July 9, 2008 Share Posted July 9, 2008 Took me a little while to work it out as well muttley Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now