我的意图是当记录中有报警时变成红色,断线时为黄色。但我在CustomDrawItem中加入代码。可是颜色并没像预期的那样改变,而是当窗体有变化时才变。大家帮我看看代码,到底哪儿有问题。
Var
SensorType:String;
WarnValue,CurValue:Real;
SiteID,SensorID:Integer;
begin
SiteID:=StrToIntDef(Copy(Trim(Item.Caption),1,2),1);
SensorID:=StrToIntDef(Copy(Trim(Item.Caption),3,2),1);
SensorType:=Copy(Trim(Item.Caption),5,1);
ListViewAll.Canvas.Font.Color:=clBlack;
if SensorType='A' then
begin
if SensorAInfo[SiteID][SensorID].Warned then
begin
if ListViewAll.Canvas.Font.Color<>clRed then
begin
ListViewAll.Canvas.Font.Color := clRed;
end;
end
else
if SensorAInfo[SiteID][SensorID].CurValue='未接' then
begin
if ListViewAll.Canvas.Font.Color<>clYellow then
ListViewAll.Canvas.Font.Color := clYellow;
end
else
begin
if ListViewAll.Canvas.Font.Color<>clGreen then
ListViewAll.Canvas.Font.Color := clGreen;
end;
end;
end;
Var
SensorType:String;
WarnValue,CurValue:Real;
SiteID,SensorID:Integer;
begin
SiteID:=StrToIntDef(Copy(Trim(Item.Caption),1,2),1);
SensorID:=StrToIntDef(Copy(Trim(Item.Caption),3,2),1);
SensorType:=Copy(Trim(Item.Caption),5,1);
ListViewAll.Canvas.Font.Color:=clBlack;
if SensorType='A' then
begin
if SensorAInfo[SiteID][SensorID].Warned then
begin
if ListViewAll.Canvas.Font.Color<>clRed then
begin
ListViewAll.Canvas.Font.Color := clRed;
end;
end
else
if SensorAInfo[SiteID][SensorID].CurValue='未接' then
begin
if ListViewAll.Canvas.Font.Color<>clYellow then
ListViewAll.Canvas.Font.Color := clYellow;
end
else
begin
if ListViewAll.Canvas.Font.Color<>clGreen then
ListViewAll.Canvas.Font.Color := clGreen;
end;
end;
end;
解决方案 »
- 哪位能详解一下“1158 当前进程已使用了 Window 管理器对象的系统允许的所有句柄。”
- 请高手给个例子,说明一下就是在什么情况下,用类是最合适的。。。。。
- 开帖散分,8/10[铁公鸡拨毛]
- 一个简单的语法问题
- 这个过程怎么调用?
- 存储过程!
- 怎样获得InputBox、InputQuery的值?
- 怎么使用本地库,又同时用SQL查询呢
- 怎样改变TstringGrid中的颜色??
- 救命啊,俺的时间都浪费在装delphi上了,俺今儿装了delphi6后许多英文都是方框框,copy到记事本又可以恢复正常,why????help
- SQL列求和问题
- 关于integer(),这函数是怎用的,返回的是什么?
CommCtrl;
function ReDrawItem(HwndLV: HWND; ItemIndex: integer): boolean;
begin
Result := ListView_RedrawItems(HwndLV, ItemIndex, ItemIndex);
end;//当记录中有报警时你就使用这句来重绘一条记录:
ReDrawItem(ListView1.handle,Item.index);贴出的代码不用改了-------------------------------------------------------
本回复由大傻的破玩意儿【CSDN's forum Explorer】完成!
软件功能强大,速度超快!!支持中...
软件下载地址:http://CoolSlob.ys168.com
你的方法不知道可以不,没试,但我觉得那样有点麻烦。