系统托盘动态图标(0分)

  • 主题发起人 主题发起人 angelface
  • 开始时间 开始时间
A

angelface

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Timer1Timer(Sender: TObject);<br>var IconData: tNotifyIconData;<br>&nbsp; &nbsp; Icon1: TIcon;<br>begin<br>&nbsp; i:=i+1; <br>&nbsp; if i&gt;4 then // 全局变量I应该小于ImageList1的图标个数。<br>&nbsp; &nbsp; i:=0;<br>&nbsp; icon1 :=TIcon.Create;<br>&nbsp; ImageList1.GetIcon(i,icon1);<br>&nbsp; IconData.cbSize := SizeOf(IconData);<br>&nbsp; IconData.wnd := Icon1.Handle;<br>&nbsp; IconData.uID := 0;<br>&nbsp; IconData.hIcon := Icon1.Handle;<br>&nbsp; IconData.uFlags := NIF_ICON;<br>&nbsp; Shell_NotifyIcon(NIM_MODIFY, @IconData);<br>&nbsp; icon1.Free;<br>&nbsp; icon1 := nil;<br>end;<br>为什么这段程序什么效果也没有?
 
你EMAIL是什么,我给你发个东西,你看看就知道了
 
tingyuanshenshen@263.net
 
发了之后告诉我一声,谢谢!~~~~<br>
 
我的QQ是:38256648,谢谢了哦!<br>
 
unit Unit1;<br>interface<br>uses<br>&nbsp; Windows, Messages, SysUtils,<br>Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs,ShellAPI, StdCtrls, ImgList, ExtCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Timer1: TTimer;<br>&nbsp; &nbsp; ImageList1: TImageList;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure FormClose(Sender: TObject; var Action: TCloseAction);<br>&nbsp; &nbsp; procedure Timer1Timer(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; lpData:PNotifyIconData;<br>&nbsp; iICon : TICon;<br>&nbsp; i: Integer=0;<br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; iICon := TIcon.Create;<br>&nbsp; ImageList1.GetIcon(i,iIcon);<br>&nbsp; lpData := new(PNotifyIconDataA);<br>&nbsp; lpData.cbSize := 88;<br>&nbsp; lpData.Wnd := Handle;<br>&nbsp; lpData.hIcon := iIcon.Handle;<br>&nbsp; lpData.uID :=0;<br>&nbsp; lpData.szTip := 'Samples';<br>&nbsp; lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br>&nbsp; Shell_NotifyIcon(NIM_ADD,lpData);<br>&nbsp; dispose(lpData);<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp; lpData := new(PNotifyIconDataA);<br>&nbsp; lpData.cbSize := 88;<br>&nbsp; lpData.Wnd := Handle;<br>&nbsp; lpData.hIcon := iIcon.Handle;<br>&nbsp; lpData.uID :=0;<br>&nbsp; lpData.szTip := 'Samples';<br>&nbsp; lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br>&nbsp; Shell_NotifyIcon(NIM_DELETE,lpData);<br>&nbsp; dispose(lpData);<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br>&nbsp; Randomize;<br>&nbsp; i:=Random(7); //取得一个随机数,这里的7为ImageList1的图标个数<br>&nbsp; ImageList1.GetIcon(i,iIcon);<br>&nbsp; lpData := new(PNotifyIconDataA);<br>&nbsp; lpData.cbSize := 88;<br>&nbsp; lpData.Wnd := Handle;<br>&nbsp; lpData.hIcon := IIcon.Handle;<br>&nbsp; lpData.uID :=0;<br>&nbsp; lpData.szTip := 'Samples';<br>&nbsp; lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br>&nbsp; Shell_NotifyIcon(NIM_MODIFY, lpData);<br>&nbsp; dispose(lpData);<br>end;<br><br>end.
 
我把一个DEMO也发给你的以下信箱:tingyuanshenshen@263.net<br><br>请查收。
 
太感谢你了~~!!!
 
发过了,你看看。如果不行我有再发详细的。
 
谢谢tryin了,我现在知道怎么办了,不过还是谢谢你!
 
后退
顶部