我定义了两个Tobjectlist对象,一个放旧的托盘列表(traylist), 一个获得当前最新的托盘列表(traylist_new), 然后从新的托盘列表中更新旧的托盘列表,
添加新托盘的代码如下:
var
i,j:integer;
traylist_new := getTraylist(traylist_new);
for i := 0 to traylist_new.Count - 1 do
begin
for j := 0 to traylist.Count - 1 do
begin if Ttrayitem(traylist_new.Items[i]).idcommand =
Ttrayitem(traylist.Items[j]).idcommand then
break
else
begin
if j = traylist.Count - 1 then
begin traylist.Add(traylist_new.Items[i]);
ShowMessage('又加了一个'); end;
end;
end;
end;
删除旧托盘的的代码如下:
for i := 0 to traylist.Count - 1 do
begin
for j := 0 to traylist_new.Count - 1 do
begin
if Ttrayitem(traylist.Items[i]).idcommand =
Ttrayitem(traylist_new.items[j]).idcommand then
Break
else
begin
if (j = traylist_new.Count-1 ) and (Ttrayitem(traylist.Items[i]).visible = True) then
begin
traylist.Delete(i);
traylist.Pack;
end;
end;
end;我隐藏一个托盘后,按理应该是要从traylist里减少一个托盘的,但是delete的那个托盘是删掉了,不过却自动把第一个托盘加到了这个位置.是怎么回事如图:
添加新托盘的代码如下:
var
i,j:integer;
traylist_new := getTraylist(traylist_new);
for i := 0 to traylist_new.Count - 1 do
begin
for j := 0 to traylist.Count - 1 do
begin if Ttrayitem(traylist_new.Items[i]).idcommand =
Ttrayitem(traylist.Items[j]).idcommand then
break
else
begin
if j = traylist.Count - 1 then
begin traylist.Add(traylist_new.Items[i]);
ShowMessage('又加了一个'); end;
end;
end;
end;
删除旧托盘的的代码如下:
for i := 0 to traylist.Count - 1 do
begin
for j := 0 to traylist_new.Count - 1 do
begin
if Ttrayitem(traylist.Items[i]).idcommand =
Ttrayitem(traylist_new.items[j]).idcommand then
Break
else
begin
if (j = traylist_new.Count-1 ) and (Ttrayitem(traylist.Items[i]).visible = True) then
begin
traylist.Delete(i);
traylist.Pack;
end;
end;
end;我隐藏一个托盘后,按理应该是要从traylist里减少一个托盘的,但是delete的那个托盘是删掉了,不过却自动把第一个托盘加到了这个位置.是怎么回事如图:
解决方案 »
- 请教QuickRep的问题。
- 怎么样判断打印机是否联机?
- DEMO字段怎么处理?
- 高分求 进销存源码
- 学delphi到了什么样的地步才能靠它来吃饭?迷茫。。。。
- 经典问题:mts,客户端运行时提示:无法创建终结点!怎么回事?
- 请各位大哥帮忙
- 改变窗口大小时窗口会抖动,我用lockwindowupdate(handle)/lockwindowupdate(0)后, 改变窗口大小时桌面会抖动,怎幺办呢
- 请高手相助把以下代码改写成vb代码,谢谢!!!另请教其中移位(位运算)是如何实现的
- 485串口通讯问题
- 如何获取当前系统system32文件夹的路径?
- 把分全部奉上,寻求解决方法.关于Connection Closed Gracefully
while traylist.Count>0 do
begin
...
end;