Save ListIcon Sort Order
- OldSkoolGamer
- Enthusiast
- Posts: 150
- Joined: Mon Dec 15, 2008 11:15 pm
- Location: Nashville, TN
- Contact:
Save ListIcon Sort Order
Is there any way to save a listicon's sort order so that on the next run of your application it sorts the same way as it was when the application was closed? Searched the forum and looked on MSDN without any success, but maybe I'm not using the correct terminology?
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Save ListIcon Sort Order
Perhaps you can record the sort order in a .txt or .ini file?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Save ListIcon Sort Order
Two procedures, one converts the current column order to a string representation like 'GCDEFAB' which could be stored in a preference file or in the registry as a string, and the other does the reverse. As ASCII capital letters are used a maximum of 26 columns are supported.
Code: Select all
Procedure.S fLSIColumnOrderGet(aListView.I)
; Convert the column order to a string representation.
; Maximum 26 columns.
Protected.I lintCols, lintNumCols, hHeader
Protected.S lstrOrder
Protected Dim larrColOrder.I(1)
If GadgetType(aListView) <> #PB_GadgetType_ListIcon
ProcedureReturn #Empty$
EndIf
hHeader = SendMessage_(GadgetID(aListView), #LVM_GETHEADER, 0, 0)
lintNumCols = SendMessage_(hHeader, #HDM_GETITEMCOUNT, 0, 0) - 1
If lintNumCols > 25
ProcedureReturn #Empty$
EndIf
ReDim larrColOrder(lintNumCols)
SendMessage_(GadgetID(aListView), #LVM_GETCOLUMNORDERARRAY, lintNumCols + 1, larrColOrder())
For lintCols = 0 To lintNumCols
lstrOrder = lstrOrder + Chr(larrColOrder(lintCols) + 65)
Next lintCols
ProcedureReturn lstrOrder
EndProcedure
Procedure fLSIColumnOrderSet(aListView.I, aOrder.S)
; Set the column order from a string representation.
; Maximum 26 columns.
Protected.I lintCols, lintNumCols
Protected.S lstrOrder
Protected Dim larrColOrder.I(1)
If GadgetType(aListView) <> #PB_GadgetType_ListIcon Or aOrder = #Empty$
ProcedureReturn
EndIf
lintNumCols = Len(aOrder) - 1
If lintNumCols > 25
ProcedureReturn
EndIf
ReDim larrColOrder(lintNumCols)
lstrOrder = UCase(aOrder)
For lintCols = 0 To lintNumCols
larrColOrder(lintCols) = Asc(Mid(aOrder, lintCols + 1, 1)) - 65
Next lintCols
SendMessage_(GadgetID(aListView), #LVM_SETCOLUMNORDERARRAY, lintNumCols + 1, larrColOrder())
EndProcedure
- OldSkoolGamer
- Enthusiast
- Posts: 150
- Joined: Mon Dec 15, 2008 11:15 pm
- Location: Nashville, TN
- Contact:
Re: Save ListIcon Sort Order
Thanks for the code Spikey, will test it out later.spikey wrote:Two procedures, one converts the current column order to a string representation like 'GCDEFAB' which could be stored in a preference file or in the registry as a string, and the other does the reverse. As ASCII capital letters are used a maximum of 26 columns are supported.