use image,
function SubSortProc(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
function SubSortProc_Neg(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
function SubSortProc(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
begin
if ParamSort=-1 then
Result := lstrcmp(PChar(TListItem(Item1).Caption),
PChar(TListItem(Item2).Caption))
else
Result := lstrcmp(PChar(TListItem(Item1).SubItems[ParamSort]),
PChar(TListItem(Item2).SubItems[ParamSort]));
end;
function SubSortProc_Neg(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
begin
if ParamSort=-1 then
Result := -lstrcmp(PChar(TListItem(Item1).Caption),
PChar(TListItem(Item2).Caption))
else
Result := -lstrcmp(PChar(TListItem(Item1).SubItems[ParamSort]),
PChar(TListItem(Item2).SubItems[ParamSort]));
end;
procedure TFm_ErrAction.LV_ErrActColumnClick(Sender: TObject;
Column: TListColumn);
var
i:integer;
begin
if Column.index>0 then
if (Column.ImageIndex=ICON_Up) or (Column.ImageIndex=-1) then
begin
TListView(Sender).CustomSort(@SubSortProc_Neg, Column.index-1);
Column.ImageIndex:=ICON_Down;
end
else if Column.ImageIndex=ICON_Down then
begin
TListView(Sender).CustomSort(@SubSortProc, Column.index-1);
Column.ImageIndex:=ICON_Up;
end;
for i:=1 to TListView(Sender).Columns.Count-1 do
if i<>Column.index then TListView(Sender).Columns.Imageindex:=-1;
end;