Post by David AyreI have had a look at CustomSort, but find the description
hard to understand.
Which version of BCB are you using? The documentation in my copy of BCB 6
is very clear about it:
TCustomListView::CustomSort
Sorts the items in the list using the specified ordering function.
typedef int (CALLBACK *PFNLVCOMPARE)(LPARAM lParam1, LPARAM lParam2,
LPARAM lParam);
bool __fastcall CustomSort(PFNLVCOMPARE SortProc, int lParam);
Description
Call CustomSort to sort the items in the list using the ordering
function defined by the SortProc parameter. The SortProc parameter specifies
an ordering function that compares the list items passed as lParam1 and
lParam2. The ordering function returns an integer that indicates whether
lParam1 is the same as lParam2 (return value is 0), lParam1 is greater than
lParam2 (return value is greater than 0), or lParam1 is less than lParam2
(return value is less than 0). The lParam parameter of CustomSort is an
optional value that is passed as the third parameter to the ordering
function.
If the SortProc parameter is NULL, CustomSort compares the list items by
generating an OnCompare event. This allows the OnCompare event handler to
provide different ordering criteria (such as ascending vs. descending
order), based on the value of the lParam parameter.
If the ordering function is not provided and there is no OnCompare event
handler, CustomSort sorts items alphabetically by their Caption values.
CustomSort returns true if the list is successfully sorted.
Warning: CustomSort does not work if the application is running in
virtual mode.
Post by David AyrePerhaps I'm a bit slow, but perhaps you could explain how to use this
function.
int CALLBACK MySortProc(TListItem *Item1, TListItem *Item2, LPARAM
lParam)
{
if (lParam == 0 )
return AnsiCompareStr(Item1->Caption, Item2->Caption);
else
return AnsiCompareStr(Item1->SubItems->Strings[lParam-1],
Item2->SubItems->Strings[lParam-1]);
}
ListView1->CustomSort((PFNLVCOMPARE)&MySortProc, SomeColumnIndex);
Gambit