Print this window

// This is in the header for the declaration
 
int __stdcall CustomSortSize(long, long, long);
FILETIME getFileDate(AnsiString, long, int);


// This is in the body
/***************************************************************************
SORT FUNCTIONS BELOW
*************************************************************************/

// Fill the ListView with the needed items and after it is filled called the
// Sort function. ie.
// First parameter is name of function to call and the other need parameter.
// lvSort->CustomSort(CustomSortDir, sf.bAscending);
// Depending upon how the sort is performed, return 1 or -1

// First 2 parameters are handled automatically for you
int __stdcall CustomSortDir(long cap1, long cap2, long sort)
{
int result;
AnsiString item1, item2;
int pos = ((TListItem *)cap1)->Caption.Pos(SEP);
item1 = ((TListItem *)cap1)->Caption.SubString(1, (pos - 1));
pos = ((TListItem *)cap2)->Caption.Pos(SEP);
item2 = ((TListItem *)cap2)->Caption.SubString(1, (pos - 1));
if (!sort)
result = -CompareText(item1, item2);
else
result = CompareText(item1, item2);
return result;
} // End the CustomSortDir function

//===========================================================================

int __stdcall CustomSortDate(long cap1, long cap2, long sort)
{
int result, which, asc;
if (sort >= CREATE_DATE_ASC)
{
asc = 1;
which = (sort - 3);
}
else
{
asc = 0;
which = sort;
}
FILETIME ft1, ft2;
AnsiString path, item1, item2, filePos;
item1 = ((TListItem *)cap1)->Caption;
item2 = ((TListItem *)cap2)->Caption;
int pos = item1.Pos(SEP);
path = item1.SubString(1, (pos - 1));
filePos = item1.SubString((pos + 1), item1.Length());
ft1 = getFileDate(path, atol(filePos.c_str()), which);
pos = item2.Pos(SEP);
filePos = item2.SubString((pos + 1), item2.Length());
ft2 = getFileDate(path, atol(filePos.c_str()), which);
if (!asc)
result = -CompareFileTime(&ft1, &ft2);
else
result = CompareFileTime(&ft1, &ft2);
return result;
} // End the CustomSortFile function