Program in the Tray
by Fons » Fri, 15 Jun 2007 05:42:59 GMT
I found an example of how to run a program with an icon in the tray and
not with a bar next to the bars of the other programs running. As long
as the program runs without displaying a window, it can run "invisible".
I have written a small clock program; just to display the time. The
problem is that when a program in the tray also displays a window, it
also gets a bar next to the other applications. You probably now what my
question is; can I make a program run with only an icon in the tray and
a window visible ?
Fons.
Re: Program in the Tray
by Rob Kennedy » Fri, 15 Jun 2007 06:49:31 GMT
What you're asking is how to prevent a window from appearing as a button
on the taskbar. Now that you know the terminology, searching should be
easier. You're asking for anything that hasn't been done a hundred times
before.
http://www.**--****.com/ +window+taskbar+button&as_ugroup=*delphi*
The fact that you have an icon in the shell notification area is
completely irrelevant.
--
Rob
Re: Program in the Tray
by Fons » Fri, 15 Jun 2007 08:05:27 GMT
Yes, I was thinking like a human being and not like a programmer; it's
not "moving" from taskbar to tray, it's removing one and creating a new
one. But 5 minutes Googling gave me:
procedure TFormMain.FormActivate(Sender: TObject);
begin
showwindow(application.handle, sw_hide);
end;
Giving me that code would've saved you some typework ;-p
And make me lazier.
Thanks for the Google,
Fons.
Re: Program in the Tray
by Heinrich Wolf » Fri, 15 Jun 2007 17:01:35 GMT
I also made such a program some years ago.
Look at http://www.**--****.com/
-> Technical info and free software
-> Download outline
-> TxtClock.exe
Regards
Heiner
Re: Program in the Tray
by Fons » Sun, 17 Jun 2007 01:58:22 GMT
Taskbar and tray are solved. But the icon in the "alt-tab-menu" is still
visible. (How) can I remove this ? No; Google didn't help. That there is
no link between taskbar and tray is clear. But that the list in the
taskbar differs from the list in the "alt-tab-menu" ?
Fons.
Re: Program in the Tray
by John Dough » Sun, 17 Jun 2007 15:58:44 GMT
On Fri, 15 Jun 2007 18:58:22 +0200, Fons
To accomplish what you're describing, you have to run your application
strictly inside the icon tray. Otherwise, whenever your main form is
active, you will have the application's icon visible in the ALT-TAB
list. As far as I know, there is no way to prevent this. Or maybe
there is, but I haven't come across it, nor have I ever needed to.
So...to tell your application to go into the icon tray, you have to
intercept the form's close event and put your code in there.
The simplest way to demonstrate this is to put a checkbox on your
form. Then you assign an OnCloseQuery event for your main form.
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose:
Boolean);
begin
canclose := (not checkbox1.Checked);
if not canclose then
begin
application.mainform.visible := false;
if iswindowvisible(application.handle) then
showwindow(application.handle,sw_hide);
end;
end;
If the checkbox is empty, then your application will close (terminate)
normally.
If the checkbox is checked, then when you close your application, it
will go into the icon tray instead of actually shutting down. You can
verify this by using the task manager in Windows to see that your
application is still running (or if you're running from inside the
IDE, then you'll see that the control isn't returned to Delphi).
Re: Program in the Tray
by Fons » Mon, 18 Jun 2007 04:33:54 GMT
The problem is that I want a small window (it's a simple program) always
being visible without the application being visible in taskbar, tray or
alt-tab menu. If you want to edit: click in the window. If you want to
close the program: double-click.
But the fact that it's not in the taskbar and tray is most of what I
wanted but I was surprised by the fact that it wasn't in the taskbar but
still visible in the alt-tab menu.
Fons.
Re: Program in the Tray
by Jamie » Mon, 18 Jun 2007 09:35:36 GMT
Try this.
Override the CreateParams for the main form, change the
class of the window which signals it to show as an icon when
minimized..
Look up CreateWindowEx and check out the creation flags.
Remove the WS_EX_APPWINDOW flag.
You may even be able to do this using the Class functions also with
out overriding.
-
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://www.**--****.com/
Re: Program in the Tray
by John Dough » Mon, 18 Jun 2007 11:43:41 GMT
On Sat, 16 Jun 2007 21:33:54 +0200, Fons
I don't think there's a way around that. The way that Windows is
designed, you will always see your application in the ALT-TAB list as
long as it has an active window on the desktop.
On my computer, I have 5 programs running in the icon tray. None of
them are visible with ALT-TAB, but as soon as I double-click on one of
them to bring up their main form, the application immediately becomes
visible in ALT-TAB (which is how it should be).
In any case, why is it important for you to make it so that your
application will not be visible in the ALT-TAB list?
Re: Program in the Tray
by Rob Kennedy » Mon, 18 Jun 2007 13:03:52 GMT
That's not true. Ever used Winamp? Or the Office toolbar? Or Google Desktop?
Supposedly the code in the following message will remove a window from
the Alt+Tab list and from the taskbar.
http://www.**--****.com/
--
Rob
Re: Program in the Tray
by John Dough » Mon, 18 Jun 2007 14:05:49 GMT
On Sat, 16 Jun 2007 23:03:52 -0500, Rob Kennedy < XXXX@XXXXX.COM >
Yes, I use it all the time, and yes, it's visible in the ALT-TAB list.
Haven't used it since they discontinued it as a default install option
(back in '98 I think).
No, I don't allow unnecessary {*filter*}onto my system.
The code listed on that link does absolutely nothing useful, unless
you click on the Minimize button of your application, in which case
you've minimized your app, and your form is no longer visible. I've
already given him a routine to do this in an earlier post which would
send his program to the icon tray in an "invisible" state.
But what he wants is to have his application's main form visible,
WHILE it's hidden on both the taskbar and the ALT-TAB list.
Re: Program in the Tray
by Rob Kennedy » Tue, 19 Jun 2007 03:19:24 GMT
Only because you have that option set. Play with the "show Winamp in"
section of the "general preferences" page for other combinations.
OK. I didn't try the code. I just repeated what the message's text said.
Anyway, it's entirely possible for a visible window to have no button on
the taskbar and no icon in the Alt+Tab list. In fact, the code from the
article I cited does exactly that for the application window. Do the
same thing for the main form, and you're all set. For example, override
the form's CreateParams method like so:
begin
inherited;
Params.ExStyle := Params.ExStyle or ws_ex_ToolWindow and not
ws_ex_AppWindow;
end;
--
Rob
Re: Program in the Tray
by Fons » Tue, 19 Jun 2007 05:51:04 GMT
What I wrote is almost nothing :-) A window (no borders) with one label
that shows the time. One click and it shows a calendar. Double-click and
it closes. It is always on top of other windows. That's it. So I don't
want it to be "in the way" of other application windows. And I never
want to alt-tab to it.
Fons.
Re: Program in the Tray
by Fons » Tue, 19 Jun 2007 06:02:24 GMT
I tried this but it doesn't work ...
... in my program.
Fons.
Similar Threads:
1.program in system tray - when to define owner?
Hi all. My program starts minimized to system tray, so the mainform
event show is not activated till later. I suspect that if I create
another form in mainform.formcreate, with the owner as mainform that
does not seem to be a reliable construct as the mainform owner is not
created yet right?
If what I suspect is right, since the form is not shown after create,
what would be the best event to place the newform.create with owner as
mainform?
Thanks,
Alistair+
2.Detecting if a tray icon program is running.
Hi,
If I am running a program called 'trayprog.exe' in the tray icon area,
how can I detect it is running through another program?
Thanks,
Greg
3.Delphi Program Launching VB Program
This is a VB question, really.
I inherited a Delphi program (Program A) which launches another Delphi
(Program B) and then quits. When Program B is finished, it re-launches
Program A and then quits. (There's a reason Program A and B quit when
finished.) I assume they're using the ShellExecute API to launch each
other.
I'm replacing Program B with a VB program, (Program C). I give it the same
name as Program B so that it gets launched automatically by Program A
instead of Program B. This works, no problem. Then Program C will
re-launch Program A, using WinAPI ShellExecute.
However, at this point, Program A (Delphi) is not able to launch Program C
(VB) again. No error messages are created. There is no indication of any
problem at all.
This all works fine when both programs are Delphi, and when both programs
are VB. I don't know Delphi and don't have access to a Delphi compiler. I
do have access to the source code if necessary, but couldn't change it. I
inherited the Delphi stuff and it's working, but I need to replace the one
component and my choice is to use VB.
Any ideas why there might be a problem re-launching the VB program from the
Delphi program the second time? The is very re-creatable. Whenever the VB
program has launched the Delphi program, the Delphi program is not able
re-launch the VB program.
Any help would be greatly appreciated.
Tom
4.Parallel program to on-line program
I'd like to write a program that runs at the same time as an on-line
program. It should be able to read the messages that are sent to the on-line
program. By on-line program I mean one that receives input from a web
connection. I suppose I'd have to discover what port was being used, by
trial and error, but I have no idea how to go about the job. Any ideas?
5.Characterizing a .NET program vs. an EXE program
6. Message map - older program needs to call new program
7. Tray Icon disappears when changing formstyle
8. Tray Icon disappears when changing formstyle (2)