Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Tue Apr 06, 2010 11:43 am
+1
... btw. where is gnozal?????
... btw. where is gnozal?????
http://www.purebasic.com
https://www.purebasic.fr/english/
I just came back from a trip, have a lot of work, so this PB4.50 thing will have to wait a little.dige wrote:+1
... btw. where is gnozal?????
Then I guess the library isn't 100% threadsafe.JJ wrote:Yes, I compile with the switch theadsafe. If I try to run the application with switch threadsafe off, the "Invalid memory error" comes immedialtely.
Code: Select all
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK fatal error: 1 unresolved external(s).
Probably a subsystem issue.PBUser wrote:Thanks for your update to 4.5x. Unfortunately I still get this POLINK errors:Code: Select all
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'. POLINK fatal error: 1 unresolved external(s).
PureLVSORT.chm wrote:This library exists in several versions :
- the standard version, located in %Purebasic%\PureLibraries\UserLibraries\ ;
- the thread-safe version, located in %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ .
- the unicode version, located in %Purebasic%\SubSystems\UserLibUnicode\PureLibraries\ .
- the unicode + thread-safe version, located in %Purebasic%\SubSystems\UserLibunicodeThreadSafe\PureLibraries\ .
In order to use this library in thread-safe mode (compiler option /THREAD), you have to enable the subsystem 'UserLibThreadSafe' in the PB IDE, or add '/SUBSYSTEM UserLibThreadSafe' to the PBCompiler arguments.
In jaPBe, do nothing : it will automatically enable the 'UserLibThreadSafe' subsystem to use the threadsafe versions of the installed userlibraries.
It's the same logic for unicode and unicode + thread-safe modes.
Code: Select all
Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventCode.l) ; simple search example
Protected itemNumber.l, I.l
Debug FilterString
If FilterString
itemNumber = -1
If IsGadget(GadgetNumber)
; Search for string
For I = 0 To CountGadgetItems(GadgetNumber) - 1
If FilterString = GetGadgetItemText(GadgetNumber, I, ListIconColumn)
itemNumber = I
Break
EndIf
Next
;
If itemNumber <> -1 ; if string found, scroll to row
PureLVSORT_ScrollToRow(GadgetNumber, itemNumber)
SetGadgetItemState(GadgetNumber, itemNumber, GetGadgetItemState(GadgetNumber, itemNumber) | #PB_ListIcon_Selected)
EndIf
EndIf
EndIf
EndProcedure
;
#Window_0 = 0
#ListIcon_0 = 0
;
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "String", 110)
AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110)
AddGadgetColumn(#ListIcon_0, 2, "Float", 110)
AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120)
AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120)
AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "0.9" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004")
AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "1.9" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004")
AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003")
AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001")
EndIf
EndProcedure
;
Open_Window_0()
;
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) ; default, not necessary
PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric)
PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float)
PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY)
PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY)
PureLVSORT_SortListIconNow(#ListIcon_0, 3, 1)
PureLVSORT_DefineFilterCallback(@MyFilterCallback())
PureLVSORT_SetFilterTimeOut(100)
PureLVSORT_SetFilter(#ListIcon_0)
EndIf
;
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
I don't have Se7en, so I can only imagine what's going wrong.QuimV wrote:Hi,
I'm testing the Filter Callback Function (in windows 7 and PB 4.41) ... and I have found that when I erase a previous FilterString entered by keyboard, the callback function receive a FilterString strange (look at "Debug FilterString "), that is not "" (empty).
Thats only occurs in W7! in WXPSP3 all runs fine.
Ok another try : I have updated http://freenet-homepage.de/gnozal/PureLVSORT_TEST.zip (PB4.50 ANSI library version, copy to \PureBasic450\PureLibraries\UserLibraries\).QuimV wrote:Hi gnozal,
The behaviour continue being wrong. I mean that when I erase the string entered by the keyboard, the gadget callback function receive a string different from "" (void string), in fact the string received by the callback function is garbage.
ye old code looks like this (ANSI PB4.xx version)QuimV wrote:Nothing good. The same behaviour.
Thanks
Code: Select all
...
ElseIf *pNMHdr\hdr\code = #HDN_FILTERCHANGE Or *pNMHdr\hdr\code = #HDN_FILTERBTNCLICK ; filter string changed
; hHDItem.HDITEM, TFilter.HDTEXTFILTER
TmpHeaderText = Space(#MAX_pszText + 1)
TFilter\pszText = @TmpHeaderText
TFilter\cchTextMax = #MAX_pszText
hHDItem\mask = #HDI_FILTER
hHDItem\type = #HDFT_ISSTRING
hHDItem\pvFilter = @TFilter
hHeader = SendMessage_(WindowId, #LVM_GETHEADER, 0, 0) ; <--- get header handle
If hHeader
SendMessage_(hHeader,#HDM_GETITEM,*pNMHdr\iItem,@hHDItem) ; <--- get filter text
If PureLVSORT_FilterCallBack
CallFunctionFast(PureLVSORT_FilterCallBack, GetDlgCtrlID_(WindowId), TFilter\pszText, *pNMHdr\iItem, *pNMHdr\hdr\code) ; passes info to the user callback
...
Code: Select all
Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventCode.l)
TFilter\pszText = @TmpHeaderText
CallFunctionFast(PureLVSORT_FilterCallBack, GetDlgCtrlID_(WindowId), TFilter\pszText, *pNMHdr\iItem, *pNMHdr\hdr\code) ; passes info to the user callback