If I tell you, does this mean you will give me "full-leech" access
Get it here!
If you know how to program, this will demonstrate how to make a tray application, with a tray icon and a popup menu, it also shows how to hide the Task Icon and the Application´s Main form.
Make note, I offer no support.
------(COPY PASTE BELOW)-------
unit unit1;
interface
uses Windows, Classes, Forms, Messages, Controls, ShellAPI, Menus, SysUtils;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
MainMenu1: TMainMenu;
Showform1: TMenuItem;
ShowApplication1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure WndProc(var Message: TMessage); override;
procedure Showform1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
IconNotifyData : TNotifyIconData;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
// Catch the Minimize event before the application
procedure TForm1.WndProc(var Message: TMessage);
var
p : TPoint;
begin
case Message.Msg of
WM_SYSCOMMAND:
case Message.WParam and $FFF0 of
SC_MINIMIZE: begin
// Hide the Mainform
Hide;
// Bail out here, so the Application dont starts to show the form
Exit;
end;
SC_RESTORE: ;
end;
WM_USER + 1:
case Message.lParam of
WM_RBUTTONDOWN: begin
GetCursorPos(p);
PopupMenu1.Popup(p.x, p.y);
end;
WM_LBUTTONDOWN: begin
Show;
end;
end;
end;
inherited ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//Now set up the IconNotifyData structure so that it receives
//the window messages sent to the application and displays
//the application's tips
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;
//Copy the Application's Title into the tip for the icon
StrPCopy(IconNotifyData.szTip Application.Title);
//Add the Icon to the system tray and use the
//the structure and its values
Shell_NotifyIcon(NIM_ADD, @IconNotifyData);
// Hide MainForm at startup.
//(Remove if application is to be shown at startup)
Application.ShowMainForm := False;
// Toolwindows dont have a TaskIcon.
//(Remove if TaskIcon is to be show when form is visible)
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
// Shows the form when user click on TrayIcon
procedure TForm1.Showform1Click(Sender: TObject);
begin
// Show the Mainform.
Show;
// Put the form in top of all others.
SetForegroundWindow(Self.handle);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @IconNotifyData);
end;