procedure TForm1.ModifyTrayIcon(Action: DWORD);
var
NIData: TNotifyIconData;
begin
with NIData do
begin
cbSize := sizeof(TNotifyIconData);
UID := 0;
uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
Wnd := Handle;
uCallBackMessage := WM_TRAYICON;
HICON := Application.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;
Shell_NotifyIcon(Action, @NIData);
end;
procedure TForm1.WMTrayIcon(var message: TMessage);
var
MousePos: TPoint;
begin
if message.LPARAM = WM_RBUTTONDOWN then
begin
SetActiveWindow(Handle);
GetCursorPos(MousePos);
PopupMenu.Popup(MousePos.X, MousePos.Y);
end;
end;