Sheitar: w sumie ok, ale np. na vsList sie troche sypie. Ja w miedzy czasie takiego kolosa wyhodowałem:
procedure TForm1.ListView1AdvancedCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
var DefaultDraw: Boolean);
var ir,r,r0,ni:TRect;
i:integer;
LV:TListView;
begin
if (Stage = cdPrePaint) and ( [cdsHot, cdsSelected] * State <> [] ) then
begin
LV:=TListView(Sender);
r:=Item.DisplayRect(drLabel);
ir:=Item.DisplayRect(drIcon);
LV.Canvas.Brush.Color:=$88ff88;
if (LV.ViewStyle = vsIcon)and(LV.LargeImages<>nil) then
LV.LargeImages.Draw(Sender.Canvas, (ir.Left + ir.Right - LV.LargeImages.Width) div 2, (ir.Top + ir.Bottom - LV.LargeImages.Height) div 2, Item.ImageIndex)
else if (LV.SmallImages<>nil) then
LV.SmallImages.Draw(Sender.Canvas, (ir.Left + ir.Right - LV.LargeImages.Width) div 2, (ir.Top + ir.Bottom - LV.SmallImages.Height) div 2, Item.ImageIndex);
if (LV.ViewStyle = vsIcon) or (LV.ViewStyle = vsSmallIcon) then
begin
LV.Canvas.FillRect(r);
DrawText(LV.Canvas.Handle,pchar(Item.Caption),-1,r,DT_CENTER or DT_WORDBREAK or DT_EDITCONTROL);
DrawFocusRect(LV.Canvas.Handle, r);
DefaultDraw:=False;
end else
begin
r0:=r;
r.Right:=r.Left;
DrawText(LV.Canvas.Handle,pchar(Item.Caption),-1,r,DT_LEFT or DT_EDITCONTROL or DT_SINGLELINE or DT_CALCRECT);
if LV.ViewStyle = vsReport then
r.Right:=r.Right+8
else
r.Right:=r.Right+4;
if r.Right>r0.Right then r.Right:=r0.Right;
r.Bottom:=r0.Bottom;
if (LV.ViewStyle = vsReport) and (LV.RowSelect) then
begin
ni:=Item.DisplayRect(drBounds);
ni.Left:=ni.Left+ir.Right;
end
else
ni:=r;
LV.Canvas.FillRect(ni);
r0:=r;
r0.Left:=r0.Left+2;
DrawText(LV.Canvas.Handle, pchar(Item.Caption), -1, r0, DT_END_ELLIPSIS or DT_SINGLELINE or DT_VCENTER);
if LV.ViewStyle = vsReport then
begin
r0:=Item.DisplayRect(drBounds);
r0.Left:=r0.Left+6;
if not(LV.RowSelect) then
LV.Canvas.Brush.Color:=LV.Color;
LV.Canvas.Refresh;
for i := 0 to Item.SubItems.Count -1 do
begin
r0.Left := r0.Left + LV.Column[i].Width;
DrawText(LV.Canvas.Handle, pchar(Item.Subitems[i]), -1, r0, DT_SINGLELINE or DT_VCENTER);
end;
if LV.RowSelect then r:=Item.DisplayRect(drBounds);
end;
DrawFocusRect(LV.Canvas.Handle, ni);
DefaultDraw:=False;
end;
end else DefaultDraw:=True;
end;
//Po drobnych poprawkach... A wydawalo by sie, ze to taka prosta sprawa ;-)
//Znowu po poprawkach ;]