const WM_TASKBAREVENT = WM_USER+1;
...
public
{ Public-Deklarationen }
procedure WMTASKBAREVENT(
var message: TMessage);
message WM_TASKBAREVENT;
end;
...
uses ShellAPI;
...
procedure TForm1.WMTASKBAREVENT(
var message: TMessage);
var point : TPoint;
begin
case message.LParamLo
of
WM_LBUTTONDBLCLK :
begin
form1.show;
end;
end;
end;
procedure TaskBarAddIcon;
var tnid : TNOTIFYICONDATA ;
begin
tnid.cbSize := sizeof(TNOTIFYICONDATA);
// Größenangabe der Struktur
tnid.Wnd := Form1.handle;
// Handle des Message-Empfängers
tnid.uID := 1;
// ID beliebig
tnid.uFlags := NIF_MESSAGE
or NIF_ICON
or NIF_TIP;
// siehe Tabelle
tnid.uCallbackMessage := WM_TASKBAREVENT;
// Message# für Form1
tnid.hIcon := form1.image1.picture.icon.handle;
// Iconhandle
strcopy(tnid.szTip,'
Programmname');
// Tooltiptext
Shell_NotifyIcon(NIM_ADD, @tnid);
// Registrieren ...
end;
procedure TaskBarRemoveIcon;
var tnid : TNOTIFYICONDATA ;
begin
tnid.cbSize := sizeof(TNOTIFYICONDATA);
tnid.Wnd := Form1.handle;
tnid.uID := 1;
Shell_NotifyIcon(NIM_DELETE, @tnid);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TaskBarAddIcon;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
TaskBarRemoveIcon;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
self.Hide;
end;