Minimize app. to "System Tray"/Program Bar Status Area??

All of you know the applications that don't show up in the Launch Bar, but instead only display a little icon at the right edge, e.g. the speaker icon, the printer icon, the dial-up monitor, but also Winfax and ICQ (to name a few "non-system" programs).

Can this be done in Delphi programs?
I tried to find a few hints in the Delphi help, but couldn't find anything useful. There is a reference to the "Taskbar status area", but no hint how to "get there".
Once again - I'd like my application to show up there minimized, but NOT be displayed in the Taskbar.

I guess 100 points are appropriate if there is an "easy" way of doing it. If this is possible but very complicated (maybe some direct WinAPI calls or the like), I'd also pay a lot more as soon as it works - whatever seems to be appropriate. I mostly answer questions (Web areas) and hardly ask any - I have lots of points available...

P.S.: I am using Delphi 3, so that shouldn't be a problem :-)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is something I have seen in one of the sites. I have made little modifications to make it work properly.
Place 3 buttons for Add, Delete and modify the Icon in the TaskBar.
Place a Popup menu with some items and write the following code:

uses ShellAPI;
var IconData :TNotifyIconData;
procedure TForm1.bbAddClick(Sender: TObject);
  with IconData DO
    cbSize := SizeOf(IconData);
    uID := 0;
    Wnd := Handle;
    szTip := 'This is my Application'+#0;
    hIcon := Application.Icon.Handle;
    uCallBackMessage := WM_USER+$10;
  if Shell_NotifyIcon(NIM_ADD,@IconData) then MessageBeep(0);

procedure TForm1.bbModifyClick(Sender: TObject);
  with IconData do
    szTip := 'app is modified'+#0;
    hIcon := LoadIcon(0,IDI_ASTERISK);
  if Shell_NotifyIcon(NIM_MODIFY,@IconData) then MessageBeep(0);

procedure TForm1.bbDeleteClick(Sender: TObject);
  if Shell_NotifyIcon(NIM_DELETE,@IconData) then MessageBeep(0);

procedure TForm1.WndProc(var MyMessage: TMessage);
var CursorPos: TPoint;
  IF MyMessage.Msg = WM_USER+$10 THEN
  CASE MyMessage.LParam OF
    PopupMenu1.Popup(CursorPos.X, CursorPos.Y);
  ShowMessage('This is my application');
  INHERITED WndProc(MyMessage);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Holger101497Author Commented:
Hey! (Almost) cool!!
Everything is easy if you know how to do it ;-)

I got it to work, but have two or three little questions left:
1) Do I need to "register" WndProc? Where? Can this be done in Delphi or do I need another API-call in the onFormCreate? It doesn't work yet.
2) I wanted the application to be "hidden". I did this by setting Visible to false but don't get it to "reappear". Is this the proper way of doing it? What would I do? Set "Visible" in the "onDblClick" and/or in the Popup-Menu?
3) Of course I want to understand what I'm doing! Where do I find the reference for "TNotifyIconData" and the other constants and functions that are used? Anything in the online help? I don't have the printed documentation with me! I'll need to do more complicated things than just place an icon and of course I have to know where to find out more about the parameters I use...

       Thanks a lot!
Holger101497Author Commented:
Oooops! Stupid me! *lol*
well, not so stupid - noticed it myself after all --- I forgot the "override" :-))
I haven't used any API-functions so far :-)
question 1) done
question 2) almost done - is there any (different) standard way of doig this? My program works, though...

only question 3 left...
I added another 25 points for a nice explanation :-))

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Usually with double click on the tray you should show your screen, but some times you add also an item in the popup menu.

This is from shellapi.pas, if you have borland source code, then you can see it there, also look in the Win32.hlp:
  TNotifyIconDataA = record
    cbSize: DWORD;
    Wnd: HWND;
    uID: UINT;
    uFlags: UINT;
    uCallbackMessage: UINT;
    hIcon: HICON;
    szTip: array [0..63] of AnsiChar;

  TNotifyIconDataW = record
    cbSize: DWORD;
    Wnd: HWND;
    uID: UINT;
    uFlags: UINT;
    uCallbackMessage: UINT;
    hIcon: HICON;
    szTip: array [0..63] of WideChar;

  TNotifyIconData = TNotifyIconDataA;
from win32.hlp:

typedef struct _NOTIFYICONDATA { // nid
    DWORD cbSize;          // sizeof(NOTIFYICONDATA)
    HWND hWnd;             // see below
    UINT uID;              // see below
    UINT uFlags;           // see below
    UINT uCallbackMessage; // see below
    HICON hIcon;           // see below
    char szTip[64];        // see below

Contains information that the system needs to process taskbar notification area messages.


Handle of the window that receives notification messages associated with an icon in the taskbar notification area.


Application-defined identifier of the taskbar icon.


Array of flags that indicate which of the other structure members contain valid data. This member can be a combination of these values:

NIF_ICON      The hIcon member is valid.
NIF_MESSAGE      The uCallbackMessage member is valid.
NIF_TIP      The szTip member is valid.

Application-defined message identifier. The system uses the specified identifier for notification messages that it sends to the window identified by hWnd whenever a mouse event occurs in the bounding rectangle of the icon.


Handle of the taskbar icon to add, modify, or delete.


Tooltip text to display for the taskbar icon.
Holger101497Author Commented:
YES! *g*

Sorry for taking such a long time with the grade - I would not have forgot it, though.

The program uses THTTP and I really can't get it to run on any computer but mine (must be some problem with registering ActiveX components and DLL's... ), so I figured I'd grade this answer as soon as everything works. Well, nobody knows how to do it :-(((

"Technically speaking", this question is answered and my other problems are not related to this question at all, so I guess I'll grade it now :-))

Thanks a lot, it all seems to work very nicely and easily :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.