如果你有Rxlib的话,实现起来比较简单,如果没有,不妨试试这个程序:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ShellAPI,
StdCtrls, Menus;
const
WM_TRAYNOTIFY = WM_USER+100;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure TrayNotifyMessage(var Sender: TMessage); message WM_TRAYNOTIFY;
procedure MarkTaskBarIcon(Sender: TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
tnd : TNOTIFYICONDATA;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize := MarkTaskBarIcon;
end;
procedure TForm1.MarkTaskBarIcon(Sender: TObject);
begin
Form1.Visible := False;
tnd.cbSize := sizeof(tnd);
tnd.Wnd := Handle;
tnd.uID := 128;
tnd.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
tnd.uCallbackMessage := WM_TRAYNOTIFY;
tnd.hIcon := Application.Icon.Handle;
StrPCopy(tnd.szTip,Application.Title);
Shell_NotifyIcon(NIM_ADD,@tnd);
end;
procedure TForm1.TrayNotifyMessage(var Sender: TMessage);
begin
if Sender.LParam = WM_LBUTTONDBLCLK then
begin
Shell_NotifyIcon(NIM_DELETE,@tnd);
Form1.Visible := True;
Application.Restore;
Application.BringToFront;
end;
if wm_size=1 then
end;
end.