PureLVSORT library : sorting ListIconGadgets (and more)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

dige wrote:... After some more tests, I've find out it depends on PureCOLOR.
Could you recompile the lib too? thx!
Ok, will do.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by dige »

gnozal wrote:
dige wrote:... After some more tests, I've find out it depends on PureCOLOR.
Could you recompile the lib too? thx!
Ok, will do.
Solved. Now it works .. thx again!
"Daddy, I'll run faster, then it is not so far..."
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Nico »

Il y a un problème avec le tri en utilisant #PureLVSORT_Alphabetic_User
Les items ne sont plus dans l'ordre :!: :?:

Voici le code de démonstration:

Code: Select all

#Window_0 = 0
#ListIcon_0 = 0

Structure Array256
  Byte.b[256]
EndStructure
UserArray.Array256
; standard ASCII values
For i = 0 To 255
  UserArray\Byte[i] = i
Next
; change some values
; UserArray\Byte[Asc("à")] = 'a'
; UserArray\Byte[Asc("â")] = 'a'
; UserArray\Byte[Asc("ù")] = 'u'
; UserArray\Byte[Asc("û")] = 'u'
; UserArray\Byte[Asc("ü")] = 'u'
; UserArray\Byte[Asc("é")] = 'e'
; UserArray\Byte[Asc("è")] = 'e'
; UserArray\Byte[Asc("ê")] = 'e'
; declare user array (before using #PureLVSORT_Alphabetic_User !)
PureLVSORT_DefineAlphabeticOrder(@UserArray)

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT User Array Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
      ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "User", 110)
      
      AddGadgetItem(#ListIcon_0, -1, "ab")
      AddGadgetItem(#ListIcon_0, -1, "aba")
      AddGadgetItem(#ListIcon_0, -1, "abb")
      AddGadgetItem(#ListIcon_0, -1, "ac")  

  EndIf
EndProcedure
Open_Window_0()
; define alphabetic order user array

; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  ;PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String)
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_Alphabetic_User)
  PureLVSORT_SortListIconNow(#ListIcon_0, 0, 1)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

Nico wrote:Il y a un problème avec le tri en utilisant #PureLVSORT_Alphabetic_User
Les items ne sont plus dans l'ordre :!: :?:
PureLVSORT does not work with one column (you may use the #LVS_SORT* styles in this case).
Try the code below :

Code: Select all

#Window_0 = 0
#ListIcon_0 = 0
Structure Array256
  Byte.b[256]
EndStructure
UserArray.Array256
; standard ASCII values
For i = 0 To 255
  UserArray\Byte[i] = i
Next
PureLVSORT_DefineAlphabeticOrder(@UserArray)
Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT User Array Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "User", 110)
    AddGadgetColumn(#ListIcon_0, 1, "", 0)
    AddGadgetItem(#ListIcon_0, -1, "abb" + Chr(10) + "")
    AddGadgetItem(#ListIcon_0, -1, "ab" + Chr(10) + "")
    AddGadgetItem(#ListIcon_0, -1, "aba" + Chr(10) + "")
    AddGadgetItem(#ListIcon_0, -1, "ac" + Chr(10) + "")  
  EndIf
EndProcedure
Open_Window_0()
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_Alphabetic_User)
  PureLVSORT_SetColumnFlag(#ListIcon_0, 1, #PureLVSORT_Column_Hidden) 
  PureLVSORT_SortListIconNow(#ListIcon_0, 0, 1)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Nico »

Dans l'exemple, je n'ai mis qu'une colonne mais c'était pour simplifier le code!
Tu peux ré-essayer avec UserLibUnicode ou UserLibUnicodeThreadSafe, car cela ne fonctionne pas chez moi avec window XP ou Vista.

In the example, I put a column but it was to simplify the code!
You can retry with UserLibUnicode or UserLibUnicodeThreadSafe because it does not work for me with window XP or Vista.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

Nico wrote:In the example, I put a column but it was to simplify the code!
You can retry with UserLibUnicode or UserLibUnicodeThreadSafe because it does not work for me with window XP or Vista.
Should be fixed in next version.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

Update (PB4.50 version)

Changes :
- fixed #PureLVSORT_Alphabetic_User issue in unicode mode.
  Note : the alphabetic order user array is now a character array (previously a byte array).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Nico »

Thanks, work very well. :)
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Fangbeast »

Hello Gnozal, I am using your library for pb4.5.

If I setup custom icons on the header, I can see them during a sort:

Code: Select all

PureLVSORT_SetUserIcons(ImageID(#Image_picsender_sortup), ImageID(#Image_picsender_sortdown))
If I add data to the ListiconGadget with icons as in:

Code: Select all

      AddGadgetItem(#Gadget_picsender_maillist, -1, CurrentFile.s + Chr(10) + Currentpath.s), ImageID(#Image_picsender_photos))
The custom sort header icons disappear.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

Hi Fangbeast, it seems to work here :

Code: Select all

Procedure Open_Window_0()
  If OpenWindow(0, 216, 0, 602, 152, "PureLVSORT Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    ListIconGadget(0, 5, 5, 590, 140, "String", 110)
    AddGadgetColumn(0, 1, "Numeric", 110)
    AddGadgetColumn(0, 2, "Float", 110)
    AddGadgetColumn(0, 3, "DateDDMMYYYY", 120)
    AddGadgetColumn(0, 4, "DateMMDDYYYY", 120)
    SomeIcon = LoadImage(2, #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico")
    AddGadgetItem(0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "0.9" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004")
    AddGadgetItem(0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "1.9" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004", SomeIcon)
    AddGadgetItem(0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003")
    AddGadgetItem(0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001", SomeIcon)
  EndIf
EndProcedure
Open_Window_0()
; User Icons
IconArrowUp.l = CatchImage(0, ?IconArrowUp)
IconArrowDown.l = CatchImage(1, ?IconArrowDown)
PureLVSORT_SetUserIcons(IconArrowUp, IconArrowDown)
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  PureLVSORT_SetColumnType(0, 0, #PureLVSORT_String) ; default, not necessary
  PureLVSORT_SetColumnType(0, 1, #PureLVSORT_Numeric)
  PureLVSORT_SetColumnType(0, 2, #PureLVSORT_Float)
  PureLVSORT_SetColumnType(0, 3, #PureLVSORT_DateDDMMYYYY)
  PureLVSORT_SetColumnType(0, 4, #PureLVSORT_DateMMDDYYYY)
  PureLVSORT_SortListIconNow(0, 1, -1)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
;{ Icons
DataSection
  IconArrowUp:
  Data.l $04C64D42,$00000000,$04360000,$00280000,$000C0000,$000C0000,$00010000,$00000008,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$C6C60000,$C8C800C6,$CECE00C8,$DEDE00CE,$EFEF00DE,$FFFF00EF,$000000FF,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$06000000,$06060606,$06060606,$06000006
  Data.l $00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006
  Data.l $00000000,$00000000,$06000006,$00000006,$06000000,$06000006,$00000606,$06060000,$06000006,$00060606,$06060600,$06000006
  Data.l $06060606,$06060606,$00000006,$00000000,$00000000
  Data.b $00,$00
  IconArrowDown:
  Data.l $04C64D42,$00000000,$04360000,$00280000,$000C0000,$000C0000,$00010000,$00000008,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$C6C60000,$C8C800C6,$CECE00C8,$DEDE00CE,$EFEF00DE,$FFFF00EF,$000000FF,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$06000000,$06060606,$06060606,$06000006
  Data.l $00060606,$06060600,$06000006,$00000606,$06060000,$06000006,$00000006,$06000000,$06000006,$00000000,$00000000,$06000006
  Data.l $00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006,$00060606,$06060600,$06000006
  Data.l $06060606,$06060606,$00000006,$00000000,$00000000
  Data.b $00,$00
EndDataSection ;}
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Fangbeast »

Yes, I can see that your ways works, mine doesn't for some reason. The below are my constants for my ListIcon and sorting images and the way I load them

Code: Select all

Enumeration #ImageIndex
  #Image_picsender_album          ; Anormal.i     family16x16.ico                       ; Normal address icon
  #Image_picsender_photos         ; Acustom.i     custom16x16.ico                       ; Custom address icon
  #Image_picsender_sortup                                                               ; sorting up
  #Image_picsender_sortdown                                                             ; sorting down
EndEnumeration

CatchImage(#Image_picsender_sortup,    ?_PTK_picsender_sortup)                          ; sorting up
CatchImage(#Image_picsender_sortdown,  ?_PTK_picsender_sortdown)                        ; sorting down
CatchImage(#Image_picsender_album,     ?_PTK_picsender_album)                           ; family16x16.ico           Normal address icon
CatchImage(#Image_picsender_photos,    ?_PTK_picsender_photos)                          ; custom16x16.ico           Custom address icon

DataSection
  _PTK_picsender_sortup     : IncludeBinary "Images\sortup12x12.ico"                    ; 
  _PTK_picsender_sortdown   : IncludeBinary "Images\sortdown12x12.ico"                  ; 

  _PTK_picsender_album      : IncludeBinary "Images\address16x16.ico"                   ; 
  _PTK_picsender_photos     : IncludeBinary "Images\camera16x16.ico"                    ; 
EndDataSection

Then in the main body of code I do the following:

Code: Select all

  PureLVSORT_SetUserIcons(ImageID(#Image_picsender_sortup), ImageID(#Image_picsender_sortdown))

; ListIcon Sort Setup

  If PureLVSORT_SelectGadgetToSort(#Gadget_picsender_maillist, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
    PureLVSORT_SetColumnType(#Gadget_picsender_maillist,     0, #PureLVSORT_String)
    PureLVSORT_SetColumnType(#Gadget_picsender_maillist,     1, #PureLVSORT_String)
    PureLVSORT_SortListIconNow(#Gadget_picsender_maillist, 0, 1)
  EndIf
And the header buttons always vanish if I add items to a ListIcon with image. By the way, "Enumeration #ImageIndex" is a continuation of the visual designer last used image index it created and I know the icons work.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

Fangbeast wrote:Yes, I can see that your ways works, mine doesn't for some reason. The below are my constants for my ListIcon and sorting images and the way I load them
I don't see any obvious problem in your posted code.
I need a small working snippet that demonstrates the issue.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Fangbeast »

gnozal wrote:
Fangbeast wrote:Yes, I can see that your ways works, mine doesn't for some reason. The below are my constants for my ListIcon and sorting images and the way I load them
I don't see any obvious problem in your posted code.
I need a small working snippet that demonstrates the issue.
Maybe the enumeration is the issue (the way I am doing it) and the icon numbers clash somewhere.

I bet if I cut out a snippet, it will probably work (LOL!). I am due to post this project shortly as it is public and see how I can cut something out of it. Thanks Gnozal.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by chi »

Why is PureLVSort not working with virtual listicon gadgets?
It seems to sort (compute) but the gadget won´t updated... Any chance for a fix?

thx, chi

Code: Select all

#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13
#ItemCount = 30000


Structure StructItems
  ItemID.s
  ItemName.s
  ItemNumber.s
EndStructure
Global Dim myItems.StructItems(#ItemCount)


Procedure WinCallback(hwnd, msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_NOTIFY
      *pnmh.NMHDR = lParam
      Select *pnmh\code
        Case #LVN_ODCACHEHINT
          result = 0
        Case #LVN_GETDISPINFO
          *pnmlvdi.NMLVDISPINFO = lParam
          If *pnmlvdi\item\mask & #LVIF_TEXT
            If *pnmlvdi\item\iSubItem = 0
              *pnmlvdi\item\pszText = @myItems(*pnmlvdi\item\iItem)\ItemID
            ElseIf *pnmlvdi\item\iSubItem = 1
              *pnmlvdi\item\pszText = @myItems(*pnmlvdi\item\iItem)\ItemName
            ElseIf *pnmlvdi\item\iSubItem = 2
              *pnmlvdi\item\pszText = @myItems(*pnmlvdi\item\iItem)\ItemNumber
            EndIf
          EndIf
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure


If OpenWindow(0, 0, 0, 640, 300, "Virtual ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  SetWindowCallback(@WinCallback())
  
  ListIconGadget(0,10,10,620,280,"ID",50,#LVS_OWNERDATA)
  AddGadgetColumn(0,1,"Name",100)
  AddGadgetColumn(0,2,"Number",100)
  
  SendMessage_(GadgetID(0), #LVM_SETITEMCOUNT, #ItemCount, #LVSICF_NOINVALIDATEALL)
  For i=0 To #ItemCount
    myItems(i)\ItemID = Str(i)
    myItems(i)\ItemName = "Name"+Str(i)
    myItems(i)\ItemNumber = Str(Random(1000))
  Next i
  
  If PureLVSORT_SelectGadgetToSort(0,#PureLVSORT_ShowClickedHeader_IconRight) = #PureLVSORT_Ok
    PureLVSORT_SetColumnType(0, 0, #PureLVSORT_Numeric)
    PureLVSORT_SetColumnType(0, 1, #PureLVSORT_String)
    PureLVSORT_SetColumnType(0, 2, #PureLVSORT_Numeric)
  EndIf
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  
EndIf
Et cetera is my worst enemy
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

chi wrote:Why is PureLVSort not working with virtual listicon gadgets?
It seems to sort (compute) but the gadget won´t updated...
PureLVSORT uses the Windows API LVM_SORTITEMS message, so virtual listicons are not supported (see MSDN article about List-View controls).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply