unit UIBandeja; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI, Menus, StdCtrls; const WM_ICONTRAY = WM_USER + 1; type TForm1 = class(TForm) PopupMenu1: TPopupMenu; Mostrar1: TMenuItem; Salir1: TMenuItem; Label1: TLabel; procedure FormCreate(Sender: TObject); procedure Mostrar1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Salir1Click(Sender: TObject); procedure Icontray(var Msg: TMessage); message WM_ICONTRAY; private { Private declarations } public { Public declarations } end; var Form1: TForm1; NotifyIconData : TNotifyIconData; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin begin with NotifyIconData do begin hIcon := Icon.Handle; StrPCopy(szTip, Application.Title); Wnd := Handle; uCallbackMessage := WM_ICONTRAY; uID := 1; uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP; cbSize := sizeof(TNotifyIconData); end; end; end; procedure TForm1.Icontray(var Msg: TMessage); var CursorPos : TPoint; begin if Msg.lParam = WM_RBUTTONDOWN then begin GetCursorPos(CursorPos); SetForegroundWindow(Handle); PopupMenu1.Popup(CursorPos.x, CursorPos.y); PostMessage(Handle, WM_NULL, 0, 0); end else inherited; end; procedure TForm1.Mostrar1Click(Sender: TObject); begin Form1.Show; Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caNone; Hide; Shell_NotifyIcon(NIM_ADD, @NotifyIconData); end; procedure TForm1.Salir1Click(Sender: TObject); begin Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); Application.ProcessMessages; Application.Terminate; end; end.