急急急 拦截任务栏图标点击事件。
时间:2011-12-19
来源:互联网
在窗口最小化后有个图标在任务栏上。
在点击任务栏上的图标是怎样拦截点击事件。
请高手解答。
先谢谢了。
在点击任务栏上的图标是怎样拦截点击事件。
请高手解答。
先谢谢了。
作者: ynquan 发布时间: 2011-12-19
自定义消息可以完成下面是代码Delphi(Pascal) code
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus,ShellApi; const MY_MESSAGE = WM_USER + 100; type TfrmMain = class(TForm) PopupMenu1: TPopupMenu; mnuIcon: TMenuItem; procedure mnuIconClick(Sender: TObject); private { Private declarations } procedure IconOnClick(var message:TMessage); message MY_MESSAGE; public { Public declarations } end; var frmMain: TfrmMain; NT:TNOTIFYICONDATA; implementation {$R *.dfm} procedure TfrmMain.IconOnClick( var message: Tmessage); var p : TPoint; begin if (message.lParam = WM_LBUTTONDOWN) then ; if (message.lParam = WM_RBUTTONDOWN) then begin GetCursorPos(p); self.PopupMenu1.Popup( p.x ,p.y ); end; end; procedure TfrmMain.mnuIconClick(Sender: TObject); begin if Pos('缩为小图标',self.mnuIcon.Caption)>0 then begin with NT do begin cbSize:=Sizeof(NT); // nid变量的字节数 Wnd:=Handle; // 主窗口句柄 UID:=0; // 内部标识,可设为任意数 uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP; uCallBackMessage:=MY_MESSAGE; hIcon:=Icon.Handle; // 要加入的图标句柄,可任意指定 szTip:='Delphi'#0; // 提示字符串 hIcon := Application.Icon.Handle; end; Application.Minimize; ShowWindow(Application.Handle,SW_HIDE); Shell_NotifyIcon(NIM_ADD,@NT); self.mnuIcon.Caption:='正常显示'; end else begin Shell_NotifyIcon(NIM_DELETE,@NT); ShowWindow(Application.Handle,SW_SHOW); Application.Restore; self.mnuIcon.Caption:='缩为小图标'; end; end; end.
作者: changsn 发布时间: 2011-12-19
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28