p; StrToFloatDef(Item.SubItems[i - 1], 0),
100,
0,
True,
//这里用了一个Lable来选颜色,你自己可以使用一个变量来代替
LableProgressColor.Color, //进度条外框颜色
LableProgressColor.Color //进度条颜色
);
end
else
//画SubItem的文字
if i - 1 <= Item.SubItems.Count - 1 then
DrawText(
LV.Canvas.Handle,
PCHAR(Item.SubItems[i - 1]),
Length(Item.SubItems[i - 1]),
Rect,
DT_VCENTER or DT_SINGLELINE or DT_END_ELLIPSIS or TextFormat);
end;
end;
end;
LV.Canvas.Brush.Color := clWhite;
if Item.Selected then //画选中条外框
begin
if cdsFocused in State then//控件是否处于激活状态
LV.Canvas.Brush.Color := $00DAA07A // $00E2B598; //clHighlight;
else
LV.Canvas.Brush.Color := $00E2B598; //$00DAA07A // clHighlight;
LV.Canvas.FrameRect(BoundRect); //
end;
DefaultDraw := False; //不让系统画了
with Sender.Canvas do
if Assigned(Font.OnChange) then Font.OnChange(Font);
end;
function ReDrawItem(HwndLV: HWND; ItemIndex: integer): boolean;
begin
Result := ListView_RedrawItems(HwndLV, ItemIndex, ItemIndex);
end;
//使用:
item:=ListView1.Selected;
item.subitems:=30;//设置为30%
//然后刷新这个item
ReDrawItem(ListView1.handle,Item.index);
不用进度条时的效果图: