Her er uniten til et eksempel jeg lagde for lenge siden:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellApi, Menus;
const
WM_TRAYICON = WM_USER + 1;
type
TForm1 = class(TForm)
pmTrayMenu: TPopupMenu;
Exit1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Exit1Click(Sender: TObject);
private
{ Private declarations }
procedure WMTrayIcon(var Msg: TMessage); message WM_TRAYICON;
public
{ Public declarations }
end;
var
Form1: TForm1;
Tray: TNotifyIconData;
implementation
{$R *.dfm}
procedure TForm1.WMTrayIcon(var Msg: TMessage);
begin
case Msg.LParam of
WM_RBUTTONUP:
begin
SetForegroundWindow(Handle);
pmTrayMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
end;
WM_LBUTTONDBLCLK: Visible := not Visible;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with Tray do
begin
cbSize := SizeOf(Tray);
Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := WM_TRAYICON;
hIcon := Application.Icon.Handle;
StrCopy(szTip, PChar(Application.Title));
end;
Shell_NotifyIcon(NIM_ADD , @Tray);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @Tray);
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Close;
end;
end.
Mvh
DiZpel