Solved

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

Posted on 1998-03-27
6
360 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
6 Comments
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
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 300 total points
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Expert Comment

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

Later

BoRiS
0
 
LVL 5

Expert Comment

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

11 Experts available now in Live!

Get 1:1 Help Now