图片怎么不能刷新?

yuehaiyang 2005-08-15 11:14:36
我在状态栏中插入了一副bmp图片,然后我在窗口上放了一个定时器,然后定时去变化图片。
但是变化图片的时候,我用tpicture的LoadFromFile方法,但是怎么图片不变呢?
...全文
121 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuehaiyang 2005-08-16
  • 打赏
  • 举报
回复
//刷新的函数
procedure tw_main.addicon(ttype :Integer);
var
tpic :TPicture;
tpath,tpath2 :string;
begin
if StatusBar1.Panels.Count = 0 then Exit;
tpic := TPicture.create;
tpath := GetCurrentDir + '\bmp\1.bmp'; //绿
tpath2 := GetCurrentDir + '\bmp\2.bmp'; //红
if not FileExists(tpath) or not FileExists(tpath2) then Exit;
StatusBar1.Panels[1].Style := psOwnerDraw ;
case ttype of
0:
begin
tpic.LoadFromFile(tpath2);
img1.picture := tpic;
img1.Parent := StatusBar1;
img1.Left := Round(Width * 0.3) + 2;
img1.Top := 1;
img1.Width := 20;
img1.Height := StatusBar1.Height;
img1.Tag := 0;
end;
1:
begin
if img1.Tag = 0 then
begin
tpic.LoadFromFile(tpath2);
img1.picture := tpic;
img1.Tag := 1;
end;
if img1.Tag = 1 then
begin
tpic.LoadFromFile(tpath);
img1.picture := tpic;
img1.Tag := 0;
end;
end;
2:
begin
tpic.LoadFromFile(tpath2);
img1.picture := tpic;
end;
end ;
end;

//定时器事件
begin
if StatusBar1.Panels.Count = 0 then exit;
if pos('未连接',tstr) > 0 then addicon(2);
if pos('已连接',tstr) > 0 then addicon(1);
if pos('连接已断开',tstr) > 0 then addicon(2);
end;
zzlingaaa 2005-08-16
  • 打赏
  • 举报
回复
代码看看再说
78hgdong 2005-08-16
  • 打赏
  • 举报
回复
应该是代码没写好相关的触发事件吧!
jixingzhong 2005-08-16
  • 打赏
  • 举报
回复
应该是可以的 !
你的代码呢 ?
loon1981 2005-08-16
  • 打赏
  • 举报
回复
代码发出来

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧