Solved

Showing program in taskpane

Posted on 2003-11-09
4
513 Views
Last Modified: 2010-04-05
How can i show my program on minimise and on load in the task pane in the bottom right hand corner near the time and the sound function?

This is instead of showing it as an application in the normal part of the task bar.

I hope you understand what i mean.

Regards,

Hypoviax
0
Comment
Question by:Hypoviax
  • 2
4 Comments
 
LVL 5

Expert Comment

by:snehanshu
ID: 9712164
This question has been asked quite frequently.
There are some freeware components that let you do it without too much coding.
Here's a previously accepted answer:

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20774429.html

Accepted Answer from kretzschmar
Date: 10/22/2003 07:55PM IST
 Accepted Answer  

well, then just go to www.torry.net
go to search keyword trayicon

there are some free components,
download one or more install it
and drop it then one your form
 

*-*-* OR *-*-*

You could do a little bit programming like in this answer:
http://www-level3.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20743321.html

Accepted Answer from cubud
Date: 09/19/2003 04:20PM IST
 Accepted Answer  

Try this, it should work but I have typed it directly into the browser and might have a compile error.  Alternately you could get a trayicon component from Torry.net :-)

in Application.OnMinimize do this
ShowWindow(Application.Handle, SW_HIDE);

This will hide the app.  To show your own icon you need to use ShellAPI and do something like this

//You need this member in your main form
private
  FIconData: TNotifyIconData;

//Put this code in your main form's OnCreate
FIconData.cbSize := SizeOf(TNotifyIconData);
FIconData.Wnd := Handle;
FIconData.uID := 1;
FIconData.uFlags := NIF_MESSAGE or NIF_TIP or NIF_ICON;
FIconData.uCallbackMessage := WM_USER;
FIconData.hIcon := Application.Icon;
FIconData.szTip := PChar(Application.Title);
//Add the icon
Shell_NotifyIcon(NIM_ADD, @FIconData);

//Put this in OnDestroy of your main form
Shell_NotifyIcon(NIM_DELETE, @FIconData);

//Finally, you need to know when the icon in the tray is double clicked
private
  procedure WMUSER(var Message: TMessage); message WM_USER;

//implementation
procedure TForm1.WMUSER(var Message: TMessage);
begin
  if Message.LParam = WM_LBUTTONDBLCLK then
  begin
    ShowWindow(Application.Handle, SW_SHOW);
    Application.Restore;
    SetForegroundWindow(Application.Handle);
  end;
end;  


HTH,
...Snehanshu
0
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 9714599
Hi,

I use this skeleton in my apps (left-click on the tray icon opens the app and right-click opens the popup menu):

uses ..., ShellApi;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu; // popup menu for the tray with two options: show and exit
    mnuTrayShow: TMenuItem;
    mnuTrayExit: TMenuItem;
     procedure ToTray;
     procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure mnuTrayShowClick(Sender: TObject);
    procedure mnuTrayExitClick(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure WndProc(var Msg : TMessage); override;
  public
    { Public declarations }
    IconNotifyData : TNotifyIconData;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses unit2, Tools;

procedure TForm1.ToTray;
begin
  Form1.Hide;
end;

procedure TForm1.WndProc(var Msg : TMessage);
var
   p : TPoint;
begin
  case Msg.Msg of
    WM_USER+1:
    case Msg.lParam of
      WM_RBUTTONUP: begin // show popup menu with two options: show and exit
        GetCursorPos(p);
        PopupMenu1.Popup(p.x, p.y);
      end;
      WM_LBUTTONUP: begin
         mnuTrayShowClick(Self);
      end;
    end;
  end;
  if (Msg.Msg = WM_SYSCOMMAND) and (Msg.wParam = SC_MINIMIZE) then begin
    ToTray;
    Msg.wParam := 0;
    Msg.lParam :=0;
  end;
  inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with IconNotifyData do begin
    hIcon :=Application.Icon.Handle;
    uCallbackMessage := WM_USER + 1;
    cbSize := sizeof(IconNotifyData);
    Wnd := Handle;
    uID := 100;
    uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
  end;
  StrPCopy(IconNotifyData.szTip, 'CD FTP');
  Shell_NotifyIcon(NIM_ADD, @IconNotifyData);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  ShowWindow(Application.Handle, SW_HIDE);
  SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Shell_NotifyIcon(NIM_DELETE, @IconNotifyData);
  Application.ProcessMessages;
end;

procedure TForm1.mnuTrayShowClick(Sender: TObject);
begin
  Form1.Show;
  Application.BringToFront;
end;

procedure TForm1.mnuTrayExitClick(Sender: TObject);
begin
  Close;
end;

end.

Regards, Geo
0
 
LVL 5

Author Comment

by:Hypoviax
ID: 9719082
Thanks for your help i believe that both were equal,

Snehanshu,

Please go to http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20793756.html for your equal share

Reagrds,

Hypoviax

0
 
LVL 17

Expert Comment

by:geobul
ID: 9720565
Thanks Hypoviax :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

24 Experts available now in Live!

Get 1:1 Help Now