From dd3a6eff7063ea29e05cc476a943bcd144f8b5d2 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Tue, 25 Jan 2005 10:44:32 +0000 Subject: [PATCH] Added: sorted column color option --- X2UtVirtualTree.pas | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/X2UtVirtualTree.pas b/X2UtVirtualTree.pas index e6fa7fa..00f3656 100644 --- a/X2UtVirtualTree.pas +++ b/X2UtVirtualTree.pas @@ -10,24 +10,47 @@ unit X2UtVirtualTree; interface uses + Graphics, VirtualTrees; //:$ Applies the sort order on the specified column //:: When a column is already sorted, the sort order is reversed. + //:: Specify a SortColor to provide the new column with that color + //:: (similar to Explorer in Windows XP). If you choose to use SortColor, + //:: the column's Tag property will be used to restore the color when calling + //:: SortColumn for the second time, so be sure not to rely on that. procedure SortColumn(const AHeader: TVTHeader; - const AColumn: TColumnIndex); + const AColumn: TColumnIndex; + const ASortColor: TColor = clNone); implementation procedure SortColumn; begin with AHeader do + begin + if (ASortColor <> clNone) and (SortColumn <> -1) then + with Columns[SortColumn] do + if Tag <> 0 then + begin + Color := TColor(Tag); + Tag := 0; + end; + if SortColumn = AColumn then SortDirection := TSortDirection(1 - Integer(SortDirection)) else begin SortColumn := AColumn; SortDirection := sdAscending; end; + + if ASortColor <> clNone then + with Columns[SortColumn] do + begin + Tag := Color; + Color := ASortColor; + end; + end; end; end.