Delphi中如何实现托盘图标 各位大虾: 请问如何实现类似qq的托盘图标,即图标出现在任务栏的右下角,然后可以操纵右下角的图标(如单击右健出现选择菜单)。 应该比较简单吧,先谢谢大家先 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 完整代码unit fshbx;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi, Menus, ExtCtrls;const WM_NOTIFYICON = WM_USER + 1;type Tserverfrom = class(TForm) PopupMenu1: TPopupMenu; about1: TMenuItem; exit1: TMenuItem; Timer1: TTimer; procedure exit1Click(Sender: TObject); procedure about1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Timer1Timer(Sender: TObject); private check: string; Notifydata: Tnotifyicondata; procedure addicon; procedure removeicon; { Private declarations } protected procedure onnotifyicon(var message: TMessage); message WM_NOTIFYICON; public { Public declarations } end;var serverfrom: Tserverfrom;implementation{$R *.DFM}procedure Tserverfrom.addicon;begin notifydata.cbSize := sizeof(notifydata); with notifydata do begin wnd := handle; uid := 1; uflags := NIF_TIP or NIF_ICON or NIF_MESSAGE; hicon := application.Icon.Handle; sztip := '应用服务器'; ucallbackmessage := WM_NOTIFYICON; end; shell_notifyicon(NIM_ADD, @notifydata);end;procedure Tserverfrom.removeicon;begin notifydata.uID := 1; shell_notifyicon(NIM_DELETE, @notifydata);end;procedure Tserverfrom.onnotifyicon(var message: Tmessage);var mousepos: Tpoint;begin if message.lparam = WM_LBUTTONDBLCLK then showmessage('不要乱动!'); if message.lparam = WM_LBUTTONDBLCLK then showmessage('左键双击'); if (message.lparam = WM_RBUTTONDBLCLK) then begin getcursorpos(mousepos); setforegroundwindow(application.handle); application.ProcessMessages; popupmenu1.Popup(mousepos.x, mousepos.y); end;end;procedure Tserverfrom.exit1Click(Sender: TObject);begin removeicon; close;end;procedure Tserverfrom.about1Click(Sender: TObject);begin showmessage('应用服务器');end;procedure Tserverfrom.FormCreate(Sender: TObject);begin addicon; showwindow(application.handle, SW_HIDE); Application.ShowMainForm := False; check :='-255';end;procedure Tserverfrom.FormClose(Sender: TObject; var Action: TCloseAction);begin removeicon;end;procedure Tserverfrom.Timer1Timer(Sender: TObject);begin removeicon; if check = '-255' then begin Application.Icon.LoadFromFile('D:\delphivcl\ico\ico\Funny\grrr!.ico'); check :='0'; end else begin Application.Icon.LoadFromFile('D:\delphivcl\ico\ico\Funny\mr remote.ico'); check :='-255'; end; addicon;end;end. 先谢过,兄台(huayuxing)应该是delphi高手吧,不知是否知道Delphi中如何实现文件的加密 sorry ,i'm not ganshou, just like you TWideStringList怎么查不到值? TlistBox问题? 线程的挂起,恢复的问题?在线等待ing 怎样用存储过程添加数据 请问如何将'112,345,234'这样的string转换成数字? 小问题。 编号问题? 简单问题 如何释放内存? 高分求解,相信并不难! 关于dbcombobox的问题 哪位有汉诺塔游戏的程序
unit fshbx;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi,
Menus, ExtCtrls;const WM_NOTIFYICON = WM_USER + 1;
type
Tserverfrom = class(TForm)
PopupMenu1: TPopupMenu;
about1: TMenuItem;
exit1: TMenuItem;
Timer1: TTimer;
procedure exit1Click(Sender: TObject);
procedure about1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Timer1Timer(Sender: TObject);
private
check: string;
Notifydata: Tnotifyicondata;
procedure addicon;
procedure removeicon;
{ Private declarations }
protected
procedure onnotifyicon(var message: TMessage); message WM_NOTIFYICON;
public
{ Public declarations }
end;
var
serverfrom: Tserverfrom;implementation{$R *.DFM}procedure Tserverfrom.addicon;
begin
notifydata.cbSize := sizeof(notifydata);
with notifydata do
begin
wnd := handle;
uid := 1;
uflags := NIF_TIP or NIF_ICON or NIF_MESSAGE;
hicon := application.Icon.Handle;
sztip := '应用服务器';
ucallbackmessage := WM_NOTIFYICON;
end;
shell_notifyicon(NIM_ADD, @notifydata);
end;procedure Tserverfrom.removeicon;
begin
notifydata.uID := 1;
shell_notifyicon(NIM_DELETE, @notifydata);
end;procedure Tserverfrom.onnotifyicon(var message: Tmessage);
var
mousepos: Tpoint;
begin
if message.lparam = WM_LBUTTONDBLCLK then
showmessage('不要乱动!');
if message.lparam = WM_LBUTTONDBLCLK then
showmessage('左键双击');
if (message.lparam = WM_RBUTTONDBLCLK) then
begin
getcursorpos(mousepos);
setforegroundwindow(application.handle);
application.ProcessMessages;
popupmenu1.Popup(mousepos.x, mousepos.y);
end;
end;procedure Tserverfrom.exit1Click(Sender: TObject);
begin
removeicon;
close;
end;procedure Tserverfrom.about1Click(Sender: TObject);
begin
showmessage('应用服务器');
end;procedure Tserverfrom.FormCreate(Sender: TObject);
begin
addicon;
showwindow(application.handle, SW_HIDE);
Application.ShowMainForm := False;
check :='-255';
end;procedure Tserverfrom.FormClose(Sender: TObject; var Action: TCloseAction);
begin
removeicon;
end;procedure Tserverfrom.Timer1Timer(Sender: TObject);
begin
removeicon;
if check = '-255' then
begin
Application.Icon.LoadFromFile('D:\delphivcl\ico\ico\Funny\grrr!.ico');
check :='0';
end
else
begin
Application.Icon.LoadFromFile('D:\delphivcl\ico\ico\Funny\mr remote.ico');
check :='-255';
end;
addicon;
end;end.