Solved

How to put an icon into the tray

Posted on 2000-03-12
11
361 Views
Last Modified: 2010-04-04
This may be really easy, but I am looking for a way to put an icon into the tray (95/98/NT) when my program is running and not have it appear on the task bar.  Any clues?
0
Comment
Question by:toesable
[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
  • 4
  • 2
  • +1
11 Comments
 

Author Comment

by:toesable
ID: 2611140
Perhaps I am doing something wrong.  Got to ftp://ftp.cdrom.com/pub but there wasn't anything in delphi_www and the full path of each of these was unavailable.  
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2611161
Thats weird - perhaps the site is down at the moment.

Try this link:

http://www.devgr.com/docs/systray.html

Cheers,

Raymond.
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 12

Expert Comment

by:rwilson032697
ID: 2611163
You could also check out the mirrors here (http://dsp.href.com/iis/iis.dll?DSP:MIRRORS:221813813) for other download locations.

Cheers,

Raymond.
0
 

Author Comment

by:toesable
ID: 2611280
devgr is for delphi 2, and it doesn't include the code only the dcu.  I'm looking for how to do it.  I will wait a few hours and try to get into the htp you reccomended.
0
 

Author Comment

by:toesable
ID: 2611862
Sorry, I am still unable to access the sites other than the one that has no source and is for delphi 2.  Perhaps I can get another answer.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2613376
Download the Tray Icon Example from the site below. It will give you all the code for doing that + sample application.

http://home.ican.net/~wniddery/freedelphistuff.html 

Cheers,

Raymond.
0
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 2613494
here an example for a animated icon in the tray:

const
  WM_MYTRAYICONCALLBACK = WM_USER + 1000;

type
  TForm1 = class(TForm)
    PopupMenu1 : TPopupMenu;
    Close1     : TMenuItem;
    Restore1   : TMenuItem;
    Timer1     : TTimer;
    procedure Close1Click(Sender: TObject);
    procedure Restore1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    HIcon1, HIcon2 : HICON;
    MyTrayIcon: TNotifyIconData;
    procedure AppMinimize(Sender:TObject);
    procedure WMMyTrayIconCallback(var Msg:TMessage);
                       message WM_MYTRAYICONCALLBACK;
  public
    { Public declarations }
  end;

{...}

procedure TForm1.FormCreate(Sender: TObject);
begin
  { load our icons }
  HIcon1 := LoadIcon(0, IDI_WINLOGO);
  HIcon2 := LoadIcon(0, IDI_HAND);

  { set TApplictaion.OnMinimize to our new event }
  Application.OnMinimize := AppMinimize;

  { start our application minimized to the System Tray }
  Visible := FALSE;
  Application.ShowMainForm := Visible;

  { required to set cbSize to SizeOf our structure }
  MyTrayIcon.cbSize := SizeOf(TNotifyIconData);

  { handle to main window }
  MyTrayIcon.Wnd    := Handle;

  { identifier of our icon }
  MyTrayIcon.uId    := 1;

  { flags showing what we are using in the other members below }
  MyTrayIcon.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;

  { our user defined message }
  MyTrayIcon.uCallBackMessage := WM_MYTRAYICONCALLBACK;

  {  set our icon to the first one loaded above }
  MyTrayIcon.hIcon  := HIcon1;

  { help message of the icon }
  MyTrayIcon.szTip  := 'Lou''s Delphi Tip of the Day [MyTrayIcon]';

  { add our icon to the tray }
  Shell_NotifyIcon(NIM_ADD, @MyTrayIcon);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  { remove our icon from the tray }
  Shell_NotifyIcon(NIM_DELETE, @MyTrayIcon);
end;

procedure TForm1.AppMinimize(Sender:TObject);
begin
  { hide our application }
  Visible := FALSE;
  Application.ShowMainForm := Visible;
end;

procedure TForm1.WMMyTrayIconCallback(var Msg:TMessage);
var
  CursorPos : TPoint;
begin
  case Msg.lParam of
    WM_LBUTTONDOWN :
      begin
        { get mouse cursor position }
        GetCursorPos(CursorPos);
        { popup our TPopupMenu }
        PopupMenu1.Popup(CursorPos.X,CursorPos.Y);
      end;
  end;
end;

procedure TForm1.Close1Click(Sender: TObject);
begin
  { close our application }
  Close;
end;

procedure TForm1.Restore1Click(Sender: TObject);
begin
  { restore our application, or minimize if already
    in a restore mode }
  Visible := TRUE;
  Application.ShowMainForm := Visible;
  SetForegroundWindow(Application.Handle);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  { change our icon to the opposite one loaded }
  if MyTrayIcon.hIcon = HIcon1 then
    MyTrayIcon.hIcon := HIcon2
  else
    MyTrayIcon.hIcon := HIcon1;

  { tell the SystemTray to modify our changes }
  Shell_NotifyIcon(NIM_MODIFY, @MyTrayIcon);
end;
0
 
LVL 2

Expert Comment

by:Tussin
ID: 2615367
I think you know how to add icon to the tray (from Raymond's suggestion)

All you want know now is "how we can hide a program from TaskBar?", right?

This is a command to hide program from Taskbar.

  ShowWindow(Application.Handle,SW_HIDE);

and this is a command to show them again
  ShowWindow(Application.Handle,SW_SHOW);


0
 
LVL 17

Expert Comment

by:inthe
ID: 2615891
Tussin,
because you dont really know what the questioner thinks you should put proposed answer as comment.it is more polite.
0
 

Author Comment

by:toesable
ID: 2617760
Thanks inthe, That's the answer I was looking for.

toe
0

Featured Post

Industry Leaders: 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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month6 days, 1 hour left to enroll

627 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