domingo, 1 de julho de 2007

Using the TTrayIcon component

Hello guys, how do you do ?

I've found a litle time today to post an litle article about the ttrayicon component that came with Delphi.

There are some samples that you can found it on the web, but all those I've have seen has a litle problem when you minimize and restore your app. The problem is that it stays two titles of your application on the start menu bar.

So lets do the job.

On onClick event of your TTrayIcon put the follow code:

Self.Show; //comment this line if your D2007 doesnt have update 1

Drop an TApplicationEvents on your form and put the follow code on OnMinimize event of your TApplicationEvents component.

triPrincipal.Visible := True; //triPrincipal is the TTrayIcon component

On OnRestore event write the follow:

//Self.Show; //uncomment this line if your D2007 doesnt have update 1
triPrincipal.Visible := False; //triPrincipal is the TTrayIcon component

Now your application will appear on windows tray without problems.

I hope you guys liked ;)

Diego M. Garcia.

Nenhum comentário: