minimize to tray?

Hello again, folks.
I’ve got the tray item and menu working perfectly, but a pile of googling and searching here provides no info on how to minimize my app to the tray (windows only), and not to the taskbar.
Can anyone shed some light on this elusive subject?

Start here.

Thanks, Wayne, but as I said in my original post, I did that already…that’s how I got the trayitem working in the first place. There’s nothing in there about “minimize to tray”, or even just minimize for that matter. Hence my request for help here. Even the old RB forums don’t seem to have any answers that I could find. Is it possible that this is something xojo just doesn’t do???

Make the window invisible, and in AppTrayItem.Action, show the window upon click on the tray item :

Select Case cause Case TrayItem.LeftMouseButton etc...

Thanks, Michel…short and sweet, but it doesn’t help me with minimizing the app. I don’t want it to go to the taskbar, and I can’t figure out how to override what the little minimize button does. Basically, I want this to mimic the behavior of a “Terminate-Stay-Resident” app. Like how your antivirus stays as an icon in the tray with no visible windows present and no taskbar item.

Plus, if the user closes the window via the little x button, it also closes the trayitem. Any way around that? Using cancelClose and window.hide() doesn’t do the job.

I know I’m asking a lot. I appreciate any help you can offer.

A Terminate Stay Resident app is in fact never terminating. Most probably it is using the same kind of techniques I am describing, or the app runs as a service in the background until the trayIcon shows the window. I did test running a windowed app as a service and it works, but I never tried to have it show a window. No idea if it would work without extra declares.

You can hide the TaskBar icon with the method described here :

You may have put the remove tray icon code in your window close instead of App.Close, or made Autoquit = True. Normally, closing a window does not quit the app. Check on that.

I believe you can start your app with no window set as default, hide the taskbar icon, install the tray icon and it will act very much like your “Terminate and stay resident”. Then when you click on the tray icon, it shows the window and you’re in business, until it is closed.

I use a TrayItem in conjunction with Window.Hide. Hide removes it from the taskbar.

Thanks guys. This is going to be much harder than I thought, but I’ll read all the info and see where it takes me.
Thanks for your help. :slight_smile:

If you don’t want your app to quit when you close all of the windows, set

app.autoquit = false

Thanks, Greg!