Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to move application from taskbar to systray (notification area)

Posted on 1998-03-27
6
Medium Priority
?
376 Views
Last Modified: 2010-04-06
Hi there,

Does anybody have any idea how to move the icon of an active application (on the win95 or winNT taskbar) to the systray area (the notification area next to the clock in the lower right corner of the taskbar). If it's not so difficult as i think then please give an example using a simple form that after starting appears on screen (and on the taskbar) and after clicking minimize removes the application from the taskbar to the systray.

Thanks for your help!

Scheiko
0
Comment
Question by:scheiko
[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
6 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360967
Hi

I have a tray icon component that you just drop on the form.  Mail your e-mail address to me at davekw@iafrica.com, and I will mail you the component with a sample.

Regards,
JB
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 1200 total points
ID: 1360968
this will show how to do it in code, i have it as a component if you wish......

add this to your public declaration

  public
    { Public declarations }
  procedure IconCallBackMessage( var Mess : TMessage ); message WM_USER
  + 100;
  end;

then on formCreate add this code ....

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';
     end;
     Shell_NotifyIcon( NIM_ADD, @Icd );
end;

add this to your formClose

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;


Then here is the proceure for the IconCallBackMessage.....

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;
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1360969
sorry forgot to give you code to hide taskbar icon

add this to hide taskbar icon in the onformCreate

ShowWindow(application.handle, SW_HIDE); //to hide icon


to show the the icon again just swop the SW_HIDE with SW_SHOW

Later

BoRiS
0
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!

 
LVL 4

Expert Comment

by:BoRiS
ID: 1360970
JimBob sorry didn't see your comment when I read the message...

Later

BoRiS
0
 
LVL 5

Expert Comment

by:inter
ID: 1360971
Hi friends,

The following one does the example you want. Since, the question is answered previously I do not claim any points.

Just cut and past the following code to an empy form

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure WndProc(var Message: TMessage);override;
  public
    { Public declarations }
    procedure UpdateIconData;
    procedure AppMinimize(Sender: TObject);
    procedure AppRestore(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
uses ShellApi;

const
  CM_TRAYICON        = CM_BASE + 64;

var
  IconData : TNotifyIconData;

procedure Tform1.UpdateIconData;
begin
  with IconData do begin
    cbSize := SizeOf(TNotifyIconData);
    Wnd := Handle;
    uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
    hIcon := Application.Icon.Handle;
    szTip := 'this is test tip';
    uCallbackMessage := CM_TRAYICON;
    uID := 0;
  end;
end;

procedure TForm1.AppMinimize(Sender: TObject);
begin
  UpdateIconData;
  Shell_NotifyIcon(NIM_ADD, @IconData);
  //Hide window on task bar
  ShowWindow(Application.Handle, SW_HIDE);
end;

procedure TForm1.AppRestore(Sender: TObject);
begin
  Shell_NotifyIcon(NIM_DELETE, @IconData);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMinimize := AppMinimize;
  Application.OnRestore := AppRestore;
end;

procedure TForm1.WndProc(var Message: TMessage);
begin
  try
    with Message do
      if Msg = CM_TRAYICON then begin
        case Message.lParam of
          WM_LBUTTONDBLCLK,
          WM_LBUTTONUP,
          WM_RBUTTONUP:  begin
                         ShowWindow(Application.Handle, SW_SHOW);
                         Application.Restore;
                         end;
        end;
      end
      else inherited WndProc(Message);
  except
    Application.HandleException(Self);
  end;
end;

end.


Regards,
Igor
0
 

Author Comment

by:scheiko
ID: 1360972
JimBoB:I'll mail you to ask you for the component.

Thanks Guys! I'll try it all until i find the one that suits me best (I think two are the same, you guys've been in class together? :)

Regards,
Scheiko
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

719 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