给我;谢了
[email protected]
[email protected]
解决方案 »
- delphi中ToolButton图标问题
- delphi生成EXE文件时检测有没dat文件才能生成exe
- 关于Form显示在Panel 上关闭的问题
- 各位帮我看看,这段VC的代码如果用delphi怎么写
- 为什么 access 在模糊查询的时候 内存益出 什么原因呢?????????
- 数据库记录删除
- 画弧线的问题
- 强大的作者软件自主发布管理系统!欢迎广大软件作者前来发布您的软件作品! http://www.softpie.com/
- 一个memo使用的问题!
- 我是一个初学者,谁能帮帮我
- 关于WM_NCPAINT
- 偶就是牛虻,发放两个源代码:机房管理系统、仪器管理系统,但有一个条件:把贴子里的问题答了,只要解决了,马上就给,注意:你解决不了,就不用留地址了
[email protected]
uses ShellApi;const WM_TRAYNOTIFY=WM_USER+1; private
{ Private declarations }
public
procedure WndProc(var Msg: TMessage); override ; { Public declarations } { Public declarations }procedure TFrmMain.FormCreate(Sender: TObject);
nid:TNotifyIconData;
beginnid.cbSize := sizeof(nid); // nid变量的字节数
nid.Wnd := Handle; // 主窗口句柄
nid.uID :=771021;
nid.hIcon := Image1.Picture.Icon.Handle;//Application.Icon.Handle; // 要加入的图标句柄,可任意指?
nid.szTip := '公路卡口'; // 提示字符串
nid.uCallbackMessage := WM_TRAYNOTIFY; // 回调函数消息
nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有?if not Shell_NotifyIcon(NIM_ADD,@nid) then
begin
ShowMessage('Failed!');
Application.Terminate ;
end;
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);end;
procedure Tfrmmain.WndProc(var Msg: TMessage);
var
IconID:integer;
pt:TPOINT;
beginif msg.Msg = WM_TRAYNOTIFY thenbegin{在通知消息中,wParam参数为图标的uID,lParam参数为鼠标事件的类型。}iconID := msg.WParam;//获取鼠标的在屏幕上的位置GetCursorPos(pt);
//通知消息的处理的基本框架结构如下:case msg.lParam ofWM_LBUTTONDOWN:begin//鼠标右键被按下end;WM_RBUTTONDOWN:begin//鼠标左键被按下end;WM_LBUTTONUP:begin//释放左键 ;end;WM_RBUTTONUP:begin PopupMenu.Popup(pt.x,pt.y); //释放鼠标右键end;WM_MOUSEMOVE:begin//鼠标在图标上移动end;WM_LBUTTONDBLCLK:beginShow;//鼠标左键双击end;WM_RBUTTONDBLCLK:begin//鼠标右键双击end;end; //end caseendelse//调用父类的WndProc方法处理其它消息inherited;end;
主要使用sheel_api
WM_TrayMessage=WM_User+100; protected
procedure AppMinimized(Sender: TObject);
procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;uses ShellApivar
NID:TNotifyIconData{点击了任务栏的图标}
procedure TMainForm.WMTrayMessage(var msg:TMessage);
var
p:TPoint;
begin
if msg.LParam=WM_LButtonDown then
begin
ShowWindow(Application.Handle,SW_Show);
Application.Restore;
end
else if msg.LParam=WM_RButtonDown then
begin
GetCursorPos(p);
pmTray.Popup(p.x,p.y);
end;
end;{应用程序最小化时图标显示在任务栏}
procedure TMainForm.AppMinimized(Sender:TObject);
begin
NID.cbSize:=SizeOf(TNotifyIconData);
NID.hIcon:=Application.Icon.Handle;
NID.szTip:= '彩虹2.0 Beta ';
NID.uCallbackMessage:=WM_TrayMessage;
NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
NID.uID:=0;
NID.Wnd:=Handle;
Shell_NotifyIcon(NIM_ADD,@NID);
ShowWindow(Application.Handle,SW_Hide);
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
end;procedure TMainForm.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NID);
end;