Solved

Tray Icon Applet - how do you do it?

Posted on 1998-12-30
9
187 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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