Solved

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

Posted on 1998-05-03
7
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 120 total points
ID: 1340658
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
ID: 1340659
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
ID: 1340660
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
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 5

Expert Comment

by:ronit051397
ID: 1340661
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
ID: 1340662
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
ID: 1340663
Well?...
0
 
LVL 6

Author Comment

by:Holger101497
ID: 1340664
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

Technology Partners: 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!

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

628 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