Solved

Tray Icon Applet - how do you do it?

Posted on 1998-12-30
9
185 Views
Last Modified: 2010-04-04
Help! I would like an applet I have written to appear in the System Tray instead of minimising. Does anyone know how I can do this in Delphi 4.0? Am I missing something obvious like Form.MinimizeMode:=mmSystemTrayIcon, or does it need one of those mumbo-jumbo H_WIND_BOLLOX API call thingies? :-) Seriously, if it is, please try to be more helpful than the Win32 API Help File?
0
Comment
Question by:PaulCutcliffe
9 Comments
 

Author Comment

by:PaulCutcliffe
ID: 1353891
Edited text of question
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1353892
Hi

You need to use the "Shell_NotifyIcon" API (declared in ShellAPI.pas) to add/remove tray icons.

There are many components that do this for you - just drop on a form, assign an icon & popup menu, and *Bingo*
I recommend you look on the Delphi Super Page (http://sunsite.icm.edu.pl/delphi/) - search for "Tray".  There are quite a few...

Cheers,
JB
0
 
LVL 17

Expert Comment

by:inthe
ID: 1353893
or here is solution without component

http://www.inquiry.com/techtips/delphi_pro/files/10min0798.htm

Regards Barry
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 17

Expert Comment

by:inthe
ID: 1353894
the use of the term 'Bollox' this means your from england right :-)

Regards Barry
(in the midlands)
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353895
Hi PaulCutcliffe, I give my two pennies :

you can read all about in this article :

http://www.delumpa.com/tips/apps/apps3.htm 

Or you can use the TrayIcon component of freeware RxLib library. Which I find very handy, because it sticks with a great free library : rx.demo.ru

Or you can use other components... lot's already on the net.
(like JimBob says)

Regards, Zif.
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1353896
PaulCutCliffe

JimBob and Zifnab are correct there a lot of components out there but here is some code to show you how it is done, I use it on the form create meathod but you can use it any where in the code...

Hi JimBob how things that side, long time no hear....

 public
    { Public declarations }
  procedure IconCallBackMessage( var Mess : TMessage ); message WM_USER
  + 100;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
   Icd : TNotifyIconData;
begin
     ShowWindow(Application.handle, SW_HIDE);
     Self.Hide;
     with Icd do
     begin
           cbSize := SizeOf( TNotifyIconData );
           Wnd := Form1.Handle;
           uID := 1;
           uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
           uCallbackMessage := WM_USER + 100;
           hIcon := Application.Icon.Handle;
           szTip := 'Cool I got it right Wooooo Weeeee';
     end;
     Shell_NotifyIcon( NIM_ADD, @Icd );
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
   Icd : TNotifyIconData;
begin
     with Icd do
     begin
           cbSize := SizeOf( TNotifyIconData );
           Wnd := Form1.Handle;
           uID := 1;
           uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
           uCallbackMessage := WM_USER + 100;
           hIcon := Application.Icon.Handle;
           szTip := 'Cool I got it right Wooooo Weeeee';
// All the above is probably not needed.
     end;
     Shell_NotifyIcon( NIM_DELETE, @Icd );
end;

procedure TForm1.IconCallBackMessage( var Mess : TMessage );
var
   sEventLog : String;
begin
     case Mess.lParam of
// Do whatever you wish here. For example popup up a menu on a right click.
          WM_LBUTTONDBLCLK  : sEventLog := 'Left Double Click';
          WM_LBUTTONDOWN    : sEventLog := 'Left Down';
          WM_LBUTTONUP      : sEventLog := 'Left Up';
          WM_MBUTTONDBLCLK  : sEventLog := 'M Dbl';
          WM_MBUTTONDOWN    : sEventLog := 'M D';
          WM_MBUTTONUP      : sEventLog := 'M U';
          WM_MOUSEMOVE      : sEventLog :=  'movement';
          WM_MOUSEWHEEL     : sEventLog := 'Wheel';
          WM_RBUTTONDBLCLK  : sEventLog := 'r dbl';
          WM_RBUTTONDOWN    : sEventLog := 'r down';
          WM_RBUTTONUP      : sEventLog := 'r up';
     end;
end;

end.

Hope this helps

Later
BoRiS
0
 

Accepted Solution

by:
mjustin earned 100 total points
ID: 1353897
Hi,

a component which does this is available free and with source code in the famous RXLib library at http://rx.demo.ru. It even supports animated try icons.

Michael Justin
http://www55.pair.com/betasoft
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1353898
Hi Michael,

you should really read the comments before answering questions.
If you look at Zif's comment from "Friday, January 01 1999 - 05:27AM", you'll see that your info brings nothing new...

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1353899
someone else not read madshi's comment either eh?
perhaps someday they will need help and find there's no one willing
  2¢

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question