Sort ListIconGadget [Windows only]

Share your advanced PureBasic knowledge/code with the community.
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: Sort ListIconGadget [Windows only]

Post by Zapman »

dcr3 wrote: Mon Mar 03, 2025 1:01 pm I haven't tested everything thoroughly in this sort module.
Many thanks to continuing to test, dcr3. That's great!

How do you proceed to test different formats? If I just do:
Global CSLI_DateFormat$ = "%yyyy-%mm-%dd"
instead of
Global CSLI_DateFormat$ = GetLocalDateFormat()
All is OK for me.
dcr3
Enthusiast
Enthusiast
Posts: 181
Joined: Fri Aug 04, 2017 11:03 pm

Re: Sort ListIconGadget [Windows only]

Post by dcr3 »

May be something like this.It's your call.

Global Dim dates.s(4)

Global CSLI_DateFormat$

Select CSLI_DateFormat$
Case dates(0)
CSLI_DateFormat$="%dd.%mm.%yyyy"
Case dates(1)
CSLI_DateFormat$="%dd-%mm-%yyyy"
Case dates(2)
CSLI_DateFormat$="%dd/%mm/%yyyy"
Case dates(3)
CSLI_DateFormat$="%yyyy.%mm.%dd"
Case dates(4)
CSLI_DateFormat$="%yyyy/%mm/%dd"
Case dates(5)
etc:..
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: Sort ListIconGadget [Windows only]

Post by Zapman »

dcr3 wrote: Mon Mar 03, 2025 4:34 pm May be something like this.It's your call.

Global Dim dates.s(4)

Global CSLI_DateFormat$

Select CSLI_DateFormat$
Case dates(0)
CSLI_DateFormat$="%dd.%mm.%yyyy"
Case dates(1)
CSLI_DateFormat$="%dd-%mm-%yyyy"
Case dates(2)
CSLI_DateFormat$="%dd/%mm/%yyyy"
Case dates(3)
CSLI_DateFormat$="%yyyy.%mm.%dd"
Case dates(4)
CSLI_DateFormat$="%yyyy/%mm/%dd"
Case dates(5)
etc:..
Sorry, dcr3, I probably don't understand what you mean :(
Line 205, instead of doing

Code: Select all

Global CSLI_DateFormat$ = GetLocalDateFormat()
I did that:

Code: Select all

Global CSLI_DateFormat$
Define Test = 5
Select Test
  Case 1
  CSLI_DateFormat$="%dd.%mm.%yyyy"
  Case 2
  CSLI_DateFormat$="%dd-%mm-%yyyy"
  Case 3
  CSLI_DateFormat$="%dd/%mm/%yyyy"
  Case 4
  CSLI_DateFormat$="%yyyy.%mm.%dd"
  Case 5
  CSLI_DateFormat$="%yyyy/%mm/%dd"
EndSelect
and everything works perfectly, whatever the value (from1 to 5), i give to 'Test'.
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: Sort ListIconGadget [Windows only]

Post by Amundo »

Thank you very much, Zapman, for sharing your nicely laid-out code.

I too, was using Nalor's module but decided to try using your one. The issue I have, is that I'm not quite sure how to handle a ListIcon gadget which gets refreshed (oddly enough, by the user clicking a "Refresh" button). Should I be trying to extract the last column selected from the "CSLI_WinLIProc" callback procedure?

(In other words, how can I know which column the user is currently sorting on and which direction, repopulate the ListIcon with new data, then reapply the same sort parameters?)

Thanks in advance for any advice,
Amundo
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: Sort ListIconGadget [Windows only]

Post by Zapman »

Amundo wrote: Thu Mar 06, 2025 4:04 amhow can I know which column the user is currently sorting on and which direction
Hi, Amundo.

Thank you for the test and for the need reporting.

The 'SortListIcon()' is called by the library to sort the gadget when the user clicks on a column title, and you can also call it to sort the gadget the way you want.

I have updated the code proposed in the first post of this subject to answer to your need. The version 'March 2025-3' offers to additionnal procedures:
- GetLastSortingColumn(GadgetNum)
- GetLastSortingAscentDescent(GadgetNum)

You can call them to get the parameters used to do the last gadget's sorting:

Code: Select all

LastColumn = GetLastSortingColumn(GadgetNum)
LastAscentDescent = GetLastSortingAscentDescent(GadgetNum)
and eventually reuse them by calling

Code: Select all

SortListIcon(GadgetNum, LastColumn, LastAscentDescent)
I hope this meets your need. Let me know if it doesn't.

This version of the library has also an improved version of the procedure 'RemoveAccents()' which is now very efficient. It is 400 times faster than the preceeding version!
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: Sort ListIconGadget [Windows only]

Post by Amundo »

Thank you, Zapman, your additions are just what the doctor ordered - it's perfect!

My program's almost like a bought one now :D


Thanks again,
Amundo
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
Post Reply