What I would do is:
o The tray icon loads your server.
o The tray icon also loads your client
o If the client is supposed to be 'hidden' the _tray_icon_ hides the
client GUI (the GUI doesn't do it itself). This will leave the client
running, just not doing anything since the window is now invisible to the
user. This is the 'tray' mode.
o When the tray icon is double clicked (or whatever) the _tray_icon_
unhides the GUI. It can easily do this if it knows what the title bar of
the GUI window is. However it is possible to unhide a window even if you
only know what process created it (and we do! since we loaded the client!)
[Freenet.exe does something similar when it needs to stop the freenet node -
it finds which window is the GUI node even though it is hidden, and sends it
a swift WM_CLOSE. In your case you would send I think a WM_SHOWWINDOW
message instead]
Leaving just the problem of the GUI minimising-itself-to-the-tray. It's
easy in C++ - just call "ShowWindow(my_hWnd, SW_HIDE);" where my_hWnd is the
window handle of your GUI app. I don't know Java however (I have a cursory
understanding of the language but that's it) but I'm sure it's a doddle.
Assuming you have a class library concerning windows (that's windows not
Windows) you should be able to derive a class and override the OnMinimize
event so that you do a ShowWindow(hWnd,SW_HIDE) instead.
Couple of points:
o Since my suggested 'tray mode' keeps the client running, you ought to
code it so it uses very few resources when it isn't doing anything
o I can forsee situations where a user might double-click on the tray
icon even when the GUI is running - you might like to make the tray not only
un-hide the window but also give it the focus and bring it to the top of the
zorder - something like SetForegroundWindow
*Alternatively:*
o When the minimize button is clicked, the client exits, taking its
window with it. This means your derived window class would implement
OnMinimize as a call to OnExit or somesuch. (Again, I don't know the Java
terminology here and I'm assuming there is indeed a window class hierarchy
that you can derive your own specific functionality from)
o When the tray icon is double clicked, the client is re-loaded (if it
isn't already running) or given the focus and made on top with
SetForegroundWindow (if it is already running)
This could prove to be easier assuming you don't need the GUI to be running
in the background (i.e. stop/start rather than minimise-to-tray /
unminimise)
Dave
Is unminimise a word?
----- Original Message -----
From: "Owen Williams" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 6:07 PM
Subject: [freenet-devl] best way to do this tray icon
> I was wondering if anyone could help me with my tray icon problem.
> here's the idea
>
>
> 1. my program, all java, runs a server and a client. They both need
> access to a special FreeDatabase object, which contans all the data for
> the program.
>
> 2. in gui mode, both the client and server are running
>
> 3. I want a tray mode, where the server is running but the client is
> not
>
> 4. one should be able to click on said icon and bring up the gui.
>
>
> so the problem is: a) how do I translate a click in windows to tell java
> to call a method, basically a "show window" method? b) how do I
> translate a minimize click on the main window to hide the window, and
> keep the tray icon?
>
> any ideas?
>
> owen
>
> _______________________________________________
> Devl mailing list
> [EMAIL PROTECTED]
> http://lists.freenetproject.org/mailman/listinfo/devl
>
_______________________________________________
Devl mailing list
[EMAIL PROTECTED]
http://lists.freenetproject.org/mailman/listinfo/devl