procedure TFmCustomLVDemo.d2_ListViewCustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
var Rect,N: TRect;
H,I:integer;
S:String;
begin
// State=cdsSelected, cdsFocused, cdsChecked
if SubItem=1
then begin
H:=0;
// richtige Koordinaten sammeln
for I:=0 to 0 do
Inc(H,Sender.Column[i].Width);
// und etwas kleiner , damit der Focusrect noch erscheinen kann
Rect.Left:= H+1;
Rect.Right:= Rect.Left + Sender.Column[1].Width-1;
Rect.Top:= Item.getposition.Y+1;
N:=Item.DisplayRect(dricon);
Rect.Bottom:= (N.Bottom)-1;
with Sender.Canvas do
begin
{if (cdsSelected in State) or
(cdsFocused in State)
then Brush.Color:=clYellow
else Brush.Color:=clWindow;}
Inc(rect.Left,2);Inc(Rect.Top,2);
Dec(Rect.Right);
Dec(Rect.Bottom,1);
//FillRect(Rect);
// text des Subitems holen
S:= Item.SubItems[Subitem-1];
Font.Size:=10;
Font.Style:=[fsBold];
Font.Color:= clBlack;
SetBkMode(
Handle,Transparent);
// text zeichnen
DrawText(
handle,@S[1],length(S),Rect,DT_SINGLELINE or DT_END_ELLIPSIS);
rect.Top:=rect.Top+10;
Font.Size:=8;
Font.Color:=clSilver;
Font.Style:=[];
s:='Hallo, hier kommt die 2. Zeile und mehr!';
DrawText(
handle,@S[1],length(S),Rect, DT_SINGLELINE or DT_END_ELLIPSIS);
rect.Top:=rect.Top+8;
Font.Size:=8;
Font.Color:=clSilver;
s:='3. Zeile';
DrawText(
handle,@S[1],length(S),Rect,DT_LEFT or DT_WORDBREAK);
end;
DefaultDraw:=false;
end;
end;