系统托盘图标在进程结束后不自动消失问题,急求解答......请高手帮忙谢谢! 我在delphi下调用了vc的exe,vc的exe启动后在系统托盘处(屏幕右下)显示一图标,当我在delphi下退出vc的exe(结束进程后),vc的系统托盘图标并不消失,只有用鼠标在系统托盘处移动才会消失。----怎么解决这个问题呢?请高手帮忙谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像托盘程序如果在进程中结束掉的话,都有这个毛病。应该让vc的这个exe正常退出,而不是结束进程。 http://community.csdn.net/Expert/topic/3808/3808152.xml?temp=.6127588看看这个,不知能帮上你吗。 http://www3.ccw.com.cn/club/essence/200303/13384.htm 在Delphi中实现系统状态栏图标(托盘图标)程序中增加使用该功能时,须在Uses中添加ShellAPI。添加图标时需要的函数是:Shell_NotifyIconA,它需要2个参数,一个参数是TnotifyIconDataA的结构,该 结构如下: TnotifyIconDataA = record cbSize: DWORD; Wnd: HWND; uID: UINT; uFlags: UINT; uCallbackMessage: UINT; hIcon: HICON; szTip: ARRAY[0..63] of AnsiChar; end; dwMessage取值为: NIM_ADD 增加一个新图标 NIM_MODIFY 修改一个已有的图标 NIM_DELETE 删除一个已有的图标实现一个Delphi中实现系统状态栏图标的窗体步骤如下:1)创建一个应用程序2)在主窗体上加一个TButton组件、一个TImage组件和一个TPopupMenu组件3)编写主窗体的mymessaage消息处理函数,此函数说明在图标上用鼠标右键单击时会弹出一个菜单4)编写TButton组件的OnClick事件及菜单项的OnClick事件5)程序源代码如下所示:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, ImgList, StdCtrls, ShellAPI, ExtCtrls;const mymsg = wm_user + 1; iid = 100;type TForm1 = class(TForm) Button1: TButton; PopupMenu1: TPopupMenu; a11: TMenuItem; b11: TMenuItem; c11: TMenuItem; Image1: TImage; procedure Button1Click(Sender: TObject); procedure c11Click(Sender: TObject); procedure a11Click(Sender: TObject); private { Private declarations } procedure mymessage(var message:tmessage); message mymsg; public { Public declarations } end;var Form1: TForm1; ntid: TnotifyIconDataA;implementation{$R *.dfm}//隐藏窗口,在托盘上显示图标procedure TForm1.Button1Click(Sender: TObject);begin ntid.cbsize := sizeof(TnotifyIconDataA); ntid.Wnd := Handle; ntid.uID := iid; ntid.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE; ntid.uCallbackMessage := mymsg; ntid.hIcon := image1.Picture.Icon.Handle; ntid.szTip := 'asdf'; shell_notifyicona(NIM_ADD,@ntid); self.Visible := false;end;//处理鼠标右键,弹出菜单procedure TForm1.mymessage(var message:tmessage );var mypt:Tpoint;begin Inherited; if message.LParam = WM_RBUTTONUP then begin getCursorPos(mypt); PopupMenu1.Popup(mypt.X, mypt.Y); end; message.rResult := 0;end;procedure TForm1.c11Click(Sender: TObject);begin close;end;//还原窗口,托盘图标消失procedure TForm1.a11Click(Sender: TObject);begin ntid.cbSize := sizeof(TnotifyIconDataA); ntid.Wnd := Handle; ntid.uID := iid; ntid.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE; ntid.uCallbackMessage := mymsg; ntid.hIcon := image1.Picture.Icon.Handle; ntid.szTip := 'asdf'; shell_notifyicona(NIM_DELETE,@ntid); self.Visible := true;end;end. 要删除的话就用Shell_NotifyIconA的 NIM_DELETE Egrid 行颜色的问题 strlist能指定tclientdataset为数据源吗 fastreport3.0和fastreport2.5 可以同时存在吗? 我的线程怎么只能执行一次 请教一个简单的问题 我想在WIN32程序里调用DOS中断,该怎么办?100分 请问这种效果的控件哪里有? 关于增删StringGrid行列的问题,以前的CSDN并未解决。 廉价的小问题:看看不妨! 怎样确认打印机是否准备好了(在报表打印前), 如果好了就打印, 不好就显示消息 修改前n条记录的问题 如何编写存储过程进行数据库之间的备份和恢复
TnotifyIconDataA = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: ARRAY[0..63] of AnsiChar;
end; dwMessage取值为:
NIM_ADD 增加一个新图标
NIM_MODIFY 修改一个已有的图标
NIM_DELETE 删除一个已有的图标
实现一个Delphi中实现系统状态栏图标的窗体步骤如下:
1)创建一个应用程序
2)在主窗体上加一个TButton组件、一个TImage组件和一个TPopupMenu组件
3)编写主窗体的mymessaage消息处理函数,此函数说明在图标上用鼠标右键单击时会弹出一个菜单
4)编写TButton组件的OnClick事件及菜单项的OnClick事件
5)程序源代码如下所示:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ImgList, StdCtrls, ShellAPI, ExtCtrls;const
mymsg = wm_user + 1;
iid = 100;type
TForm1 = class(TForm)
Button1: TButton;
PopupMenu1: TPopupMenu;
a11: TMenuItem;
b11: TMenuItem;
c11: TMenuItem;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure c11Click(Sender: TObject);
procedure a11Click(Sender: TObject);
private
{ Private declarations }
procedure mymessage(var message:tmessage);
message mymsg;
public
{ Public declarations }
end;var
Form1: TForm1;
ntid: TnotifyIconDataA;implementation{$R *.dfm}//隐藏窗口,在托盘上显示图标
procedure TForm1.Button1Click(Sender: TObject);
begin
ntid.cbsize := sizeof(TnotifyIconDataA);
ntid.Wnd := Handle;
ntid.uID := iid;
ntid.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE;
ntid.uCallbackMessage := mymsg;
ntid.hIcon := image1.Picture.Icon.Handle;
ntid.szTip := 'asdf';
shell_notifyicona(NIM_ADD,@ntid); self.Visible := false;
end;//处理鼠标右键,弹出菜单
procedure TForm1.mymessage(var message:tmessage );
var
mypt:Tpoint;
begin
Inherited;
if message.LParam = WM_RBUTTONUP then
begin
getCursorPos(mypt);
PopupMenu1.Popup(mypt.X, mypt.Y);
end;
message.rResult := 0;
end;procedure TForm1.c11Click(Sender: TObject);
begin
close;
end;//还原窗口,托盘图标消失
procedure TForm1.a11Click(Sender: TObject);
begin
ntid.cbSize := sizeof(TnotifyIconDataA);
ntid.Wnd := Handle;
ntid.uID := iid;
ntid.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE;
ntid.uCallbackMessage := mymsg;
ntid.hIcon := image1.Picture.Icon.Handle;
ntid.szTip := 'asdf';
shell_notifyicona(NIM_DELETE,@ntid);
self.Visible := true;
end;end.