Board index » delphi » Hiding icon in taskbar. Please help

Hiding icon in taskbar. Please help

Hello,

I am looking for a way to hide the icon from the tasbar. The reason is
that i have a program that has to stay in the tray and must not appear
in the traybar even if i maximize the main form. I want the program
only to appear in the tray.

In VB it was easy; only set the "ShowInTaskbar" to false. I tried in
Delphi ShowWindow (FrmMain.Handle, SW_HIDE) and that works (the main
form is invisible at startup), but ShowWindow (Applicaion.Handle,
SW_HIDE) doesn't work. The icon still appears in the taskbar.

Who has the solution for my problem? If possible, post some code,
cause i'm new to Delphi (and i definately don't want to go back to
VB).

I am using Delphi 3 Standard with Windows 95.

Many thanks on beforehand for you time.

Phranc

PS Could you please CC to my e-mail address; i don't get all messages
from my ISP.

=================
The optimist thinks this is the best of all possible worlds.
The pessimist fears it is true.
=================

http://huizen.dds.nl/~phranc

 

Re:Hiding icon in taskbar. Please help


U2hvd1dpbmRvdyggQXBwbGljYXRpb24uSGFuZGxlLCBTV19ISURFICkgc2hvdWxkIGRvIHRoZSB0
cmljaw0KVGhhdCBpcywgeW91IGp1c3QgaGlkZSB0aGUgd2luZG93LiBUaGUgdGFza2JhciBpY29u
IHdpbGwgc3RpbGwgYmUgdmlzaWJsZS4uDQoNCi0gQWFydG8gUmVwb25lbiAtDQoNCkVNYWlsCSAg
OmFhcnRvLnJlcG9uZW5AbWJveDMwMS5zd2lwbmV0LnNlDQpIVFRQCSAgOmh0dHA6Ly93d3cuYWxn
b25ldC5zZS9+YWFydG8NClZvaWNlbWFpbCA6QWFydG9AcHViMS5pcG4udm9jYWx0ZWMuY29tDQpJ
Q1EgVUlOICAgOjExNTg4MzQNCg0KLSBGTUJveCAtIA0KU29mdHdhcmUgdG8gY29udHJvbCB5b3Vy
IFJhZGlvIFJldmVhbCBhbmQgUmFkaW9UcmFjayBGTS10dW5lciBhZGFwdGVyDQoNCmh0dHA6Ly93
d3cuYWxnb25ldC5zZS9+YWFydG8vZm1ib3gNCg0KDQogUGhyYW5jIHdyb3RlIGluIGFydGljbGUg
PDMzZTZlYWIwLjE0MzAxMTJAbmV3cy54czRhbGwubmw+Li4uDQo+SGVsbG8sDQo+DQo+SSBhbSBs
b29raW5nIGZvciBhIHdheSB0byBoaWRlIHRoZSBpY29uIGZyb20gdGhlIHRhc2Jhci4gVGhlIHJl
YXNvbiBpcw0KPnRoYXQgaSBoYXZlIGEgcHJvZ3JhbSB0aGF0IGhhcyB0byBzdGF5IGluIHRoZSB0
cmF5IGFuZCBtdXN0IG5vdCBhcHBlYXINCj5pbiB0aGUgdHJheWJhciBldmVuIGlmIGkgbWF4aW1p
emUgdGhlIG1haW4gZm9ybS4gSSB3YW50IHRoZSBwcm9ncmFtDQo+b25seSB0byBhcHBlYXIgaW4g
dGhlIHRyYXkuDQoNCg==

Re:Hiding icon in taskbar. Please help


Phranc,
        ShowWindow(Application.Handle, SW_HIDE) won't work if you try to rename
your app title (Application.Title) AFTER you've hidden the window.  Just
make sure that you don't change the name after hiding the window, and it'll
work.

                                Derek Moore
                                de...@alastria.com

--
Phranc <phr...@dds.nl.nospam> wrote in article
<33e6eab0.1430...@news.xs4all.nl>...

Quote
> Hello,

> I am looking for a way to hide the icon from the tasbar. The reason is
> that i have a program that has to stay in the tray and must not appear
> in the traybar even if i maximize the main form. I want the program
> only to appear in the tray.

> In VB it was easy; only set the "ShowInTaskbar" to false. I tried in
> Delphi ShowWindow (FrmMain.Handle, SW_HIDE) and that works (the main
> form is invisible at startup), but ShowWindow (Applicaion.Handle,
> SW_HIDE) doesn't work. The icon still appears in the taskbar.

> Who has the solution for my problem? If possible, post some code,
> cause i'm new to Delphi (and i definately don't want to go back to
> VB).

> I am using Delphi 3 Standard with Windows 95.

> Many thanks on beforehand for you time.

> Phranc

> PS Could you please CC to my e-mail address; i don't get all messages
> from my ISP.

> =================
> The optimist thinks this is the best of all possible worlds.
> The pessimist fears it is true.
> =================

> http://huizen.dds.nl/~phranc

Re:Hiding icon in taskbar. Please help


Quote
Phranc wrote:
> I am looking for a way to hide the icon from the tasbar. The reason is
> that i have a program that has to stay in the tray and must not appear
> in the traybar even if i maximize the main form. I want the program
> only to appear in the tray.

> In VB it was easy; only set the "ShowInTaskbar" to false. I tried in
> Delphi ShowWindow (FrmMain.Handle, SW_HIDE) and that works (the main
> form is invisible at startup), but ShowWindow (Applicaion.Handle,
> SW_HIDE) doesn't work. The icon still appears in the taskbar.

You've gotten a number of responses saying that
ShowWindow(Application.Handle, SW_HIDE) should work, but you're right:
In D3 it doesn't. (I haven't tried to find out why - my guess is that
they changed the windows style or extended style bits.)

However,

  SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

*does* work in D3. Just put it in your dpr file, after
Application.Initialize.

--

Personal Pages              http://www.midnightbeach.com/jon
Programming Publications    http://www.midnightbeach.com/jon/pubs
Homeschool Resource Page    http://www.midnightbeach.com/hs

Re:Hiding icon in taskbar. Please help


Quote
On Sun, 03 Aug 1997 20:34:41 GMT, phr...@dds.nl.nospam (Phranc) wrote:
>Hello,
>I am looking for a way to hide the icon from the tasbar. The reason is
>that i have a program that has to stay in the tray and must not appear
>in the traybar even if i maximize the main form. I want the program
>only to appear in the tray.
>In VB it was easy; only set the "ShowInTaskbar" to false. I tried in
>Delphi ShowWindow (FrmMain.Handle, SW_HIDE) and that works (the main
>form is invisible at startup), but ShowWindow (Applicaion.Handle,
>SW_HIDE) doesn't work. The icon still appears in the taskbar.
>Who has the solution for my problem? If possible, post some code,
>cause i'm new to Delphi (and i definately don't want to go back to
>VB).

<snip>

Well, it appears that things have changed in Delphi 3. If you include
the following code before the form appears, it gets hidden from the
taskbar:

SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

Still use ShowWindow (FrmMain.Handle, SW_HIDE) to hide the form on
your screen.

And i want to thank Pete Ness for this solution! He has a nice vcl for
an icon in the taskbar (trayicon.zip on the DSP) and together with
this code it works just fine.

Phranc

=================
The optimist thinks this is the best of all possible worlds.
The pessimist fears it is true.
=================

http://huizen.dds.nl/~phranc

Re:Hiding icon in taskbar. Please help


Hi there,

Here is a trick that will work. :-) Although you can use the
WS_EX_TOOLWINDOW trick, this gives you "proper" looking dialogs and is
suggest by MS ;-)

Just create a "dummy" main form. This form will NEVER be shown so make
it some small, empty box or whatever. Make sure that your Traybar icon
is visible at all times. Do the following:

1) Create your application.
2) Add TWO forms, the first is your DUMMY main window, the second (and
more) will be the dialogs you want.
3) Change your DPR (application source), by adding the following lines
just before the "Application.Run" line:

program Project1;

uses
  Forms,
  Windows,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
{ add these next two lines}
  Application.ShowMainForm:=false;
  ShowWindow(Application.Handle,SW_HIDE);
{}
  Application.Run;
end.

- this will hide the mainform (actually, it will prevent it from ever
appearing - i.e. no flicker) and hides the app too.

4) Make sure you can exit the program through your TrayIcon.

Also remember to code your dialogs to just Show/Hide as necessary (do
not minimize them ;-)

Thats it!

Cheers,
George.---
_Snappy_ Software

Quote
Phranc wrote:

> Hello,

> I am looking for a way to hide the icon from the tasbar. The reason is
> that i have a program that has to stay in the tray and must not appear
> in the traybar even if i maximize the main form. I want the program
> only to appear in the tray.

> In VB it was easy; only set the "ShowInTaskbar" to false. I tried in
> Delphi ShowWindow (FrmMain.Handle, SW_HIDE) and that works (the main
> form is invisible at startup), but ShowWindow (Applicaion.Handle,
> SW_HIDE) doesn't work. The icon still appears in the taskbar.

> Who has the solution for my problem? If possible, post some code,
> cause i'm new to Delphi (and i definately don't want to go back to
> VB).

> I am using Delphi 3 Standard with Windows 95.

> Many thanks on beforehand for you time.

> Phranc

> PS Could you please CC to my e-mail address; i don't get all messages
> from my ISP.

> =================
> The optimist thinks this is the best of all possible worlds.
> The pessimist fears it is true.
> =================

> http://huizen.dds.nl/~phranc

Other Threads