Solved

Tray Icon Applet - how do you do it?

Posted on 1998-12-30
9
182 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
Comment Utility
Edited text of question
0
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
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
Comment Utility
or here is solution without component

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

Regards Barry
0
 
LVL 17

Expert Comment

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

Regards Barry
(in the midlands)
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now