Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tray icon 2

Status
Not open for further replies.

Gigatech

Programmer
Jul 12, 2000
80
CR
How can I run my delphi7 application as a tray icon ?
 
You cannot run an application as a tray icon.

What you need to do is to put a tray icon component onto your main form and then select an appropriate icon for it. This icon will then be shown in the system tray.

Start your application minimized so it wont show up at startup. When the icon is clicked or double-clicked you just maximize your app.

You can propably attach a menu also to that tray icon of yours. Go to select VCL from the top and then select Tray Icons from the right menu. There should be some free tray icon components for you to choose from.

JP
 
There are a few free tray icon components around, including those supplied with D7 Pro (LMD tools and ABC tools both have one - the LMD version needs no runtimes with it, the ABC tools needs a runtime, but is easier to use).

I use the LMDtrayicon (from the LMD Sys tab) as follows:
[ul]
[li]Drop an [tt]LMDtrayicon[/tt] component on the form[/li]
[li]Set the following properties:[/li]
[ul circle]
[li]Active := FALSE[/li]
[li]Icon := <your application icon>[/li]
[li]Hint := 'A suitable hint when you mouse over the icon'[/li]
[/ul]
[li]Add the following code:
Code:
// in your declarations, create a procedure....
  public
    { Public declarations }
    procedure AppHide(Sender : TObject);
  end;

// --------------------------------------------------

procedure TMain.FormCreate(Sender: TObject);
begin
  Application.OnMinimize := AppHide; // calls this when minimised
end;

// --------------------------------------------------

procedure TMain.AppHide(Sender: TObject);
  begin
    TrayIcon.Active := TRUE; // activates tray icon when minimised
  end;

// --------------------------------------------------

procedure TMain.TrayIconClick(Sender: TObject);
begin
  TrayIcon.Active := false; // restores it when tray icon clicked
  Application.Restore;
end;

// --------------------------------------------------
[/li]
[/ul]
In its simplest form, this works fine, but you can include pop-ups etc as required - check out the help file.

And don't forget to search this forum for other methods - there are many ways to do this!

Good luck

Chris ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top