Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Showing program in taskpane

Posted on 2003-11-09
4
Medium Priority
?
552 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 500 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

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!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

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