procedure Tfrm_Main.ListView2CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
var
r, r2: TRect;
i, p: Integer;
OldBkMode:Integer;
begin
if subitem<>2
then begin
DefaultDraw:=True;
exit;
end;
DefaultDraw:=False;
r:=item.DisplayRect(drBounds);
for i:=0
to SubItem -1
do
r.left:=r.left+ListView2.Columns[i].Width;
r.right:=r.left+ListView2.Columns[SubItem].Width;
//ShowMessage(Inttostr(SubItem)+' '+inttostr(ListView2.Columns[SubItem].Width));
//r:=rect(r.left+1, r.top+1, r.right-1, r.bottom-1);
ListView2.Canvas.Brush.color:=clGreen;
listView2.canvas.FrameRect(r);
r2:=r;
r2.right:=r2.left+Trunc(ListView2.Columns[SubItem].Width*(strtoint(Item.subItems[2])/strtoint(Item.subItems[0])));
r2:=rect(r2.left+1, r2.top+1, r2.right-1, r2.bottom-1);
with ListView2.Canvas
do begin
brush.color:=clRed;
if Trunc((strtoint(Item.subItems[2])/strtoint(Item.subItems[0]))*100) < 100
then
brush.Color:=$007269D3;
if Trunc((strtoint(Item.subItems[2])/strtoint(Item.subItems[0]))*100) < warnung
then begin
brush.Color:=clBlue;
if gewarnt.IndexOf(Item.Caption)=-1
then
gewarnt.Add(Item.Caption);
end;
if Trunc((strtoint(Item.subItems[2])/strtoint(Item.subItems[0]))*100) < 30
then
brush.Color:=clLime;
fillrect(r2);
OldBkMode := SetBkMode(
Handle, TRANSPARENT);
TextOut(r.Left+Trunc((r.Right-r.Left-TextWidth(inttostr(Trunc((strtoint(Item.subItems[2])/strtoint(Item.subItems[0]))*100))+'
%'))/2),r.Top,inttostr(Trunc((strtoint(Item.subItems[2])/strtoint(Item.subItems[0]))*100))+'
%');
SetBkMode(
Handle, OldBkMode);
Brush.color:=ListView2.color;
end;
end;