unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> Menus,ShellAPI;<br> const<br> mousemsg=wm_user+1;<br> iid=100;<br><br>type<br> TForm1 = class(TForm)<br> PopupMenu1: TPopupMenu;<br> Exit: TMenuItem;<br> procedure FormCreate(Sender: TObject);<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> procedure ExitClick(Sender: TObject);<br> private<br> procedure mousemessage(var message:tmessage);message mousemsg;<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> ntida:TNotifyIcondataA;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.mousemessage (var message:tmessage);<br>var<br> mousept:TPoint;<br>begin<br> inherited;<br> if message.LParam=wm_rbuttonup then begin<br> getcursorpos(mousept);<br> popupmenu1.Popup(mousept.x,mousept.y);<br> end;<br> if message.LParam=wm_lbuttonup then<br> begin<br> ShowWindow(Handle,sw_show);<br> ShowWindow(Application.handle,SW_SHOW);<br> SetWindowLong(Application.Handle,GWL_eXSTYLE,not (GetWindowLong(Application.handle,gwl_exstyle)or ws_ex_toolwindow and not ws_ex_appwindow));<br> end;<br>end;<br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> ntida.cbSize:=sizeof(tnotifyicondataa);<br> ntida.Wnd:=handle;<br> ntida.uID:=iid;<br> ntida.uFlags:=nif_icon+nif_tip+nif_message;<br> ntida.uCallbackMessage:=mousemsg;<br> ntida.hIcon:=Application.Icon.Handle;<br> ntida.szTip:='Icon';<br> shell_notifyicona(NIM_ADD,@ntida);<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> Action:=caNone;<br> ShowWindow(Handle,SW_HIDE);<br> ShowWindow(Application.Handle,Sw_HIDE);<br> SetWindowLong(Application.Handle,GWL_EXSTYLE,GETWindowLong(Application.handle,GWL_exstyle)or ws_ex_toolwindow and ws_ex_appwindow);<br>end;<br><br>procedure TForm1.ExitClick(Sender: TObject);<br>begin<br> ntida.cbSize:=sizeof(tnotifyicondataa);<br> ntida.Wnd:=handle;<br> ntida.uID:=iid;<br> ntida.uCallbackMessage:=nif_icon+nif_tip+nif_message;<br> ntida.hIcon:=Application.Icon.Handle;<br> ntida.szTip:='Icon' ;<br> Shell_notifyicona(NIM_DELETE,@ntida);<br> Application.Terminate;<br>end;<br><br>end.