I stedet for at bruge komponenter kan du ligeså godt bruge TNotifyIconData. Det fylder også mindre, og her er et eksempel, som tilføjer et ikon, med dit programs ikon, til processlinien, og som lukker programmet når du højreklikker:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Shellapi, ExtCtrls;
const WM_TrayMessage = WM_USER + 1;
type
TMain = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
public
procedure TrayMessage(var message: TMessage); message WM_TrayMessage;
end;
var
Main: TMain;
Tray : TNotifyIconData;
implementation
{$R *.dfm}
procedure TMain.TrayMessage(var message: TMessage);
begin
if Message.LParam = WM_LBUTTONUP then
Application.Terminate;
end;
procedure TMain.FormCreate(Sender: TObject);
begin
with Tray do
begin
cbSize := SizeOf(Tray);
Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage:= WM_TrayMessage;
hIcon := Application.Handle;
szTip := 'Process ikon';
end;
Shell_NotifyIcon(NIM_ADD, @Tray);
end;
procedure TMain.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @Tray);
end;
_______________________________________
-----------------------{ nife}------------------------_______________________________________