Solved

Tray Icon Applet - how do you do it?

Posted on 1998-12-30
9
189 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 105
Installshield for Embarcadero EX 10.1 Berlin 4 72
Delphi Firemonkey send email on Android 1 38
how can i delete one control based on its tagstring ? 6 34
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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