Program çalıştığında, hiç bir yerde görünmediği halde, ikonunu Windows görev
çubuğuna yerleştirecektir. Üzerinde sağ fare tuşuna basılarak açılacak menü
ile görünür hale getirilebilir.

Unit1.dfm;
unit Unit1;

interface

uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, ShellAPI, Menus;

const WM_MINIMALIZE = WM_USER + 1
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
Show1: TMenuItem;
Hide1: TMenuItem;
Quit1: TMenuItem;

procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Show1Click(Sender: TObject);
procedure Hide1Click(Sender: TObject);
procedure Quit1Click(Sender: TObject);
private
FIconData : TNotifyIconData;
public
procedure WMMinimalize(var Message : TMessage); message WM_MINIMALIZE;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var i : Integer;
begin
with FIconData do
begin
cbSize := SizeOf(FIconData);
Wnd := Self.Handle;
uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
hIcon := Application.Icon.Handle;
uCallbackMessage := WM_MINIMALIZE; szTip := 'My own application';
end;
Shell_NotifyIcon(NIM_ADD, @FIconData);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @FIconData);
end;

procedure TForm1.WMMinimalize(var Message : TMessage);
var p : TPoint;
begin
case Message.LParam of
WM_RBUTTONUP: begin
GetCursorPos(p);
PopupMenu1.Popup(p.x, p.y);
end;
end;
end;

procedure TForm1.Show1Click(Sender: TObject);
begin
Form1.Visible := TRUE;
ShowWindow(Application.Handle, SW_HIDE);
end;

procedure TForm1.Hide1Click(Sender: TObject);
begin
Self.Visible := FALSE;
end;

procedure TForm1.Quit1Click(Sender: TObject);
begin
Application.Terminate;
end;

end.
Project1.dpr;
program Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.ShowMainForm := FALSE;
Application.Run;
end.