如何使任务栏中的小图标动起来?(150分)

  • 主题发起人 主题发起人 Delphi1998
  • 开始时间 开始时间
D

Delphi1998

Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序运行后在任务栏会出现一个小图标,但不知如何使它动起来?
 
在程序中设一个计数器,在OnTimer里面改变<br>图标,我在VC里面做过,Delphi里面做就简单<br>得多了,方一个ImageList,动态的更换Index行了<br>IF you have any error about it THEN <br>&nbsp; sendmailtome; &nbsp;<br><br>Good Luck!
 
如果你有一套Icon可配成动画的话,做一个timer,<br>定时更新Application.Icon
 
可以具体些吗?
 
RXLIB中有一个控件可以实现,如果你要用代码,我写一段你参考参考,可能有错,<br>Var<br>&nbsp; i:integer;<br>procedure time1Ontime.....<br>begin<br>i := (i+1) mod 10;<br>showicon(icons);//showicon是你用来显示ICON的函数,<br>end;<br>
 
RXLIB中有一个控件可以实现,如果你要用代码,我写一段你参考参考,可能有错,<br>Var<br>&nbsp; i:integer;<br>procedure time1Ontime.....<br>begin<br>i := (i+1) mod 10;<br>showicon(icons);//showicon是你用来显示ICON的函数,做个ICON数组,调入需要的ICON<br>end;<br>
 
下面控件里的例子可以实现任务栏上的动画小图标,是用Timer实现的。<br>&lt;a href="http://personal.wol.com.cn/grass/Trayicon.zip"&gt;Trayicon.zip&lt;/a&gt;<br>
 
我认为较好的方法是用“线程”来实现您想要的功能;因为TIMER在您的主线程忙的<br>时候是无法及时触发的;<br>具体步骤如下:<br>1、定义一个用于修改ICON的线程:<br>&nbsp; type<br>&nbsp; tchgicon = class(TThread) //用来改变图标的线程<br>&nbsp; private<br>&nbsp; &nbsp; current:integer;//用于指示当前显示的图标的序号<br>&nbsp; public<br>&nbsp; &nbsp; procedure Execute; override;<br>&nbsp; &nbsp; constructor Create;<br>&nbsp; end;<br>var<br>&nbsp; YouThread:tchgicon;<br>2、定义相应的方法和函数:<br><br>procedure Tfrm_main.modicon(mi:Hicon;mtip:string) ;<br>//修改ICON的函数<br>var<br>&nbsp; res:boolean;<br>&nbsp; ptnd:PNotifyIconData;<br>begin<br>&nbsp; new(ptnd);<br>&nbsp; ptnd^.cbsize:=sizeof(TNotifyIcondata);<br>&nbsp; //cbsize为TNotifyIcondata的字节数<br>&nbsp; ptnd^.wnd:=frm_main.handle;//建立图标的父窗口的句柄<br>&nbsp; ptnd^.uID:=0;//为同组图标的统一标识符<br>&nbsp; ptnd^.Uflags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;<br>&nbsp; //表示下面三个参数是否有效<br>&nbsp; ptnd^.uCallbackMessage:=WM_USER_NOTIFYICON;//自定义的消息<br>&nbsp; //定义触发的消息标识<br>&nbsp; ptnd^.hicon:=mi;//定义图标的句柄<br>&nbsp; strcopy(ptnd^.sztip,pchar(mtip));//定义Mouse放在ICON上的显示的Tip<br>&nbsp; res:=Shell_NotifyIcon(NIM_Modify,ptnd);<br>&nbsp; //为NIM_modify表示变更ICON<br>&nbsp; dispose(ptnd);<br>end;<br>constructor tchgicon.Create();<br>begin<br>&nbsp; current:=0;<br>&nbsp; inherited Create(False);<br>end;<br><br>procedure tchgicon.Execute;<br>var<br>&nbsp; i:integer;<br>&nbsp; res:bool;<br>begin<br>&nbsp; { Place thread code here }<br>&nbsp; i:=1;<br>&nbsp; while (not terminated) do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;current:=((current+1) mod 4);<br>&nbsp; &nbsp; &nbsp;//循环current from 1 to 4 或者你想要的数目<br>&nbsp; &nbsp; &nbsp;myhicon:=icon[current+1];<br>&nbsp; &nbsp; //取得图标的句柄,可以存在一个图标数组或ImageList中<br>&nbsp; &nbsp; &nbsp;frm_main.MOdIcon(myhicon,'It is '+inttostr(current));<br>&nbsp; &nbsp; //调用改变ICON的函数;<br>&nbsp; &nbsp; &nbsp;sleep(1000);//定时为1秒钟改变一次<br>&nbsp; &nbsp; &nbsp;if Terminated then Exit;<br>&nbsp; &nbsp;end;<br>end;<br><br>3、在你向状态栏添加加图标时创建此线程:<br>&nbsp; YouThread:=tchgicon.create();<br>4、在你从状态栏删除图标时删除此线程<br>&nbsp; YouThread.destroy;<br>最后希望您能成功!<br>如果有何问题的话我可以传一个源程序给您。<br><br>
 
如果您是想改变系统通知区域的图标(SystemTray),<br>我提请大家注意, 调用Modify之前不妨再用一次Add,<br>这样可以保证当Explorer崩溃时, 您的程序还可以<br>显示在那里出图标. (我的Explorer经常崩溃, 虽然还会自动重新启动一份, 但是这时原先在SystemTray上的图标全不见了, :(,自己稍微麻烦一下, 就可以避免<br>这个问题.:)
 
daiji:<br>您好!<br><br>您的方法我也十分感兴趣,能E-mail给我吗?<br><br>cgf@gzic.guangzhou.gd.cn
 
Delphi1998兄:<br>&nbsp; 您问的问题我也十分感兴趣,<br>&nbsp; 好东西大家一起来享用,<br>&nbsp; 能E-mail给我吗?<br>&nbsp; 谢谢!<br>daiji兄:<br>&nbsp; 能在您的Email的抄送栏里填入:<br>&nbsp; xftang@263.net吗?<br>&nbsp; 谢谢!<br>
 
邮件打开后都是乱码,可以用附加文件的方式传送给我,好吗?<br><br>非常谢谢!<br><br>
 
我是用附加文件的方式传送的,附件是源程序的ZIP包;<br>看在150的份上,只好再传一次了
 
------net911024964-ease1250----<br>Content-Type: multipart/x-zip; name="/youwant.zip"<br>Content-Transfer-Encoding: base64<br>Content-Disposition: attachment; filename="/youwant.zip"<br><br>UEsDBBQAAAAIAC26bSUWUGxfJAgAAF0YAAAOAAAAd3N0YXR1c2Jhci5wYXPtWN1vG8cRfzfg<br>/2EfiuhYsyRlq0FxBB9sUh8ETFIwqRqB4QrHuyW59d3t5XZpmQn6x8RGG0N10SiSLKGOlbRW<br>kVjWh2sZdeCXvrhFmiAP6YNR1HXR2b29D36IcowgfSkfpN3Z2dmZ2d/MzlzXJRwtMW7wLmsa<br>fv7kiZMniMux3zJMLCZdhtnJEwhdJK5Fl1gaVTBjRhvDqN5jC5zYMCraBmOCNOsbXoeYgkRd<br>7lOxOEN9B/6ViGHTNksLYayDbdvwCMjgVpH7tpTrduHf9DWuCKVzajDrE0vOw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c6VRaS+lQXX1IKUOkhtEdx6wIX8JauIy<br>JbID/itiesLQg8t34CC8AYs+hj45I2flDr1L7uzBhD3M1ccYW6ywwY65xp5jQHMuZBoMsizV<br>qZApMngBUEsBAhQAFAAAAAgALbptJRZQbF8kCAAAXRgAAA4AAAAAAAAAAQAgALaBAAAAAHdz<br>dGF0dXNiYXIucGFzUEsBAhQAFAAAAAgALbhtJWIiwLQoAgAABQQAAAwAAAAAAAAAAQAgALaB<br>UAgAAFB3c3RhdHVzLmRvZlBLAQIUABQAAAAIAFu6bSUMBF/DWwMAAGMHAAAOAAAAAAAAAAAA<br>IAC2gaIKAAB3c3RhdHVzYmFyLmRmbVBLAQIUABQAAAAIAPpLGyUiVxOHvwAAAEMBAAAMAAAA<br>AAAAAAEAAAC2gSkOAABQd3N0YXR1cy5jZmdQSwECFAAUAAAACABIuW0l7ePTHg4CAAB0EAAA<br>CwAAAAAAAAAAACAAtoESDwAAeW91SWNvbi5yZXNQSwECFAAUAAAACAAduG0lT3q2mPYAAABb<br>AQAADAAAAAAAAAABACAAtoFJEQAAUHdzdGF0dXMuZHByUEsBAhQAFAAAAAgAGWSHJMEH8mnb<br>AAAAbAMAAAwAAAAAAAAAAAAgALaBaRIAAFB3c3RhdHVzLnJlc1BLBQYAAAAABwAHAJkBAABu<br>EwAAAAA=<br><br>------net911024964-ease1250------<br>请dai ji大虾传到论坛上下载可以防止以上情况的出现。谢谢。<br>以上是接收到的邮件内容。
 
你应该将该ZIP文件保存到本地,再用WINZIP解压。如果不行<br>试试这个链接:&lt;a href=http://www.nease.net/~lgldj/youwant.zip&gt;youwant.zip
 
谢谢dai ji的程序,用进程的想法的确很好.<br><br>请斑竹为dai ji--&gt;100分,littlegrass--&gt;50分
 
为何斑竹还不分配分数给dai ji和littlegrass两位大虾呢?
 
版主很忙啊!不能总来看所有贴子,<br><br>幸亏多人得分系统快做好了,<br>不然大家最好还是用e-mail通知版主<br>分配方案.
 
后退
顶部