对呀——上面miaofeng的代码已经都贴出来了,把它拷贝到你的程序里还不会吗?????<br>再贴一次:<br>uses shellapi;<br>////////////////////////////////////////////<br>const<br> WM_MYTRAYICONCALLBACK = WM_USER + 1000 ;<br>private<br> MyTrayIcon : TNotifyIconData ;<br><br> procedure WMMyTrayIconCallBack(Var Msg : TMessage);<br> message WM_MYTRAYICONCALLBACK ;///处理托盘消息过程<br>////////////////////////////////////////////<br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Icon.Handle := LoadIcon(Hinstance,'MAINICON');<br> MyTrayIcon.cbSize := SizeOf(TNotifyIconData);<br> MyTrayIcon.Wnd := Handle ;<br> MyTrayIcon.uID := 1 ;<br> MyTrayIcon.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE ;<br> MyTrayIcon.uCallBackMessage := WM_MYTRAYICONCALLBACK ;<br> MyTrayIcon.hIcon := Icon.Handle;<br> StrCopy (MyTrayIcon.szTip, PChar(Caption));<br> Shell_NotifyIcon(NIM_ADD,@MyTrayIcon);<br> //下面不让程序在任务栏上显示(缩放到托盘中 )<br> ShowWindow(Handle,sw_Hide);<br> Visible := False ;<br> Application.ShowMainForm := False ;<br> SetForegroundWindow(Application.Handle);<br>end;<br>//删除托盘图标<br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> MyTrayIcon.uFlags := 0;<br> Shell_NotifyIcon(NIM_DELETE,@MyTrayIcon);<br>end;<br><br>///处理托盘消息(鼠标左键/右键/双击)<br>procedure TForm1.WMMyTrayIconCallBack(var Msg: TMessage);<br>var CursorPos : TPoint;<br>begin<br> case Msg.LParam of<br> WM_LBUTTONDBLCLK : begin<br> Visible := not Visible ;<br> Application.ShowMainForm := Visible ;<br> SetForegroundWindow(Application.Handle);<br> if Visible then<br> begin<br> Application.Restore;<br> Application.BringToFront;<br> end;<br> end ;<br> WM_RBUTTONDOWN : begin<br> GetCursorPos(CursorPos);<br> Popupmenu1.Popup(CursorPos.X,CursorPos.Y);//右键弹出的菜单<br> end ;<br> end ;<br>end;<br>///<br><br>已经全面了