Solved

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

Posted on 1998-05-03
7
295 Views
Last Modified: 2010-04-06
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 :-)
0
Comment
Question by:Holger101497
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 120 total points
Comment Utility
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);
begin
  with IconData DO
  begin
    cbSize := SizeOf(IconData);
    uFlags := NIF_ICON OR NIF_TIP OR NIF_MESSAGE;
    uID := 0;
    Wnd := Handle;
    szTip := 'This is my Application'+#0;
    hIcon := Application.Icon.Handle;
    uCallBackMessage := WM_USER+$10;
  end;
  if Shell_NotifyIcon(NIM_ADD,@IconData) then MessageBeep(0);
end;

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

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

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

0
 
LVL 6

Author Comment

by:Holger101497
Comment Utility
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!
0
 
LVL 6

Author Comment

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

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

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

Q3:
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;
  end;

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

  TNotifyIconData = TNotifyIconDataA;
....
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
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
} NOTIFYICONDATA, *PNOTIFYICONDATA;
 

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

hWnd

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

uID

Application-defined identifier of the taskbar icon.

uFlags

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.
uCallbackMessage

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.

hIcon

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

szTip

Tooltip text to display for the taskbar icon.
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Well?...
0
 
LVL 6

Author Comment

by:Holger101497
Comment Utility
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 :-)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

20 Experts available now in Live!

Get 1:1 Help Now