Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Tue May 11, 2010 2:14 pm
Ok, will do.dige wrote:... After some more tests, I've find out it depends on PureCOLOR.
Could you recompile the lib too? thx!
http://www.purebasic.com
https://www.purebasic.fr/english/
Ok, will do.dige wrote:... After some more tests, I've find out it depends on PureCOLOR.
Could you recompile the lib too? thx!
Solved. Now it works .. thx again!gnozal wrote:Ok, will do.dige wrote:... After some more tests, I've find out it depends on PureCOLOR.
Could you recompile the lib too? thx!
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
PureLVSORT does not work with one column (you may use the #LVS_SORT* styles in this case).Nico wrote:Il y a un problème avec le tri en utilisant #PureLVSORT_Alphabetic_User
Les items ne sont plus dans l'ordre![]()
![]()
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
Should be fixed in next version.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.
Code: Select all
PureLVSORT_SetUserIcons(ImageID(#Image_picsender_sortup), ImageID(#Image_picsender_sortdown))
Code: Select all
AddGadgetItem(#Gadget_picsender_maillist, -1, CurrentFile.s + Chr(10) + Currentpath.s), ImageID(#Image_picsender_photos))
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 ;}
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
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
I don't see any obvious problem in your posted code.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
Maybe the enumeration is the issue (the way I am doing it) and the icon numbers clash somewhere.gnozal wrote:I don't see any obvious problem in your posted code.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 need a small working snippet that demonstrates the issue.
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
PureLVSORT uses the Windows API LVM_SORTITEMS message, so virtual listicons are not supported (see MSDN article about List-View controls).chi wrote:Why is PureLVSort not working with virtual listicon gadgets?
It seems to sort (compute) but the gadget won´t updated...