tray unden component
Hvad gør jeg forkert herunit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TrayMessage (var Msg: TMessage);
private
TrayIconData: TNotifyIconData;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowMainForm := False;
with TrayIconData do
begin
cbSize := SizeOf(TrayIconData);
Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
// uCallbackMessage := WM_ICONTRAY;
hIcon := form1.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;
Shell_NotifyIcon(NIM_ADD, @TrayIconData);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @TrayIconData);
end;
procedure TForm1.TrayMessage(var Msg: TMessage);
begin
case Msg.lParam of
WM_LBUTTONDOWN:
begin
ShowMessage('hej');
Form1.Visible := true;
end;
WM_RBUTTONDOWN:
begin
Form1.Visible := false;
end;
end;
end;
end.