unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
PaintBox1: TPaintBox;
procedure ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
procedure FormCreate(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DrawRect(ACanvas:TCanvas; ARect:TRect);
begin
with ACanvas do begin
// Hintergrund löschen
Brush.Color := clWhite;
Brush.Style := bsSolid;
FillRect(ARect);
InflateRect(ARect, -2, -2);
// Rechteck zeichnen
Pen.Color := clBlack;
Pen.Style := psSolid;
Brush.Color := clRed;
Brush.Style := bsCross;
Rectangle(ARect);
end;
end;
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
R : TRect;
begin
DefaultDraw := false;
R := Item.DisplayRect(drBounds);
DrawRect(Sender.Canvas, R);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with Listview1 do begin
ViewStyle := vsReport;
with Columns do begin
Clear;
with Add do Caption := 'Col1';
end;
with Items do begin
Clear;
with Add do begin
Caption := 'dummy1';
end;
with Add do begin
Caption := 'dummy2';
end;
end;
end;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
DrawRect(Paintbox1.Canvas, Paintbox1.ClientRect);
end;
end.