Používal si hotové komponenty, alebo si skúšal aj API funkcie? Skús aj tento kód (i keď vravíš, že si skúšal už viac spôsobov, skús ešte tento):
Kód:
uses
(* ... *), ShellAPI;
type
TForm1 = class(TForm)
//...
procedure WndProc(var Message: TMessage); override; // toto pripíš medzi ostatné funkcie
private
IconNotifyData : TNotifyIconData;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WndProc(var Message: TMessage);
begin
case Message.Msg of
WM_SYSCOMMAND: case Message.WParam and $FFF0 of
SC_MINIMIZE: begin
Hide;
Exit;
end;
SC_RESTORE: ;
end;
WM_USER + 1: if (Message.LParam = WM_LBUTTONDOWN) then Show;
end;
inherited;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with IconNotifyData do begin
hIcon := Application.Icon.Handle;
uCallbackMessage := WM_USER + 1;
cbSize := sizeof(IconNotifyData);
Wnd := Handle;
uID := 100;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
end;
StrPCopy(IconNotifyData.szTip, Application.Title);
Shell_NotifyIcon(NIM_ADD, @IconNotifyData);
Application.ShowMainForm := False;
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;