//刷新的函数
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;