简体   繁体   中英

Effective way to make a system tray application

This is my first post on Stack Overflow and I'm just wondering on the options of making a system tray application. The application would run primary from the system tray while still operating, and could be brought up into a window when clicked on. It is also needed to have some support for global keystroke tracking, to bring up a window.

I'm curious on what options I have available to me, as I'm sure that there are many ways to do this. I'm most familiar with with Java though I have some experience with C++. I'm willing to explore other languages if they have some definite perks to them, though it would be nice to work with what I know in a way.

Thank you

Java 6 has new functionality which allows for the creation of applications which use the system tray.

The New System Tray Functionality in Java SE 6 article goes into the details, and provides some sample code as well.

The newly added SystemTray and TrayIcon classes of the java.awt package can be used to add icons to the system tray. The icons can respond to mouse clicks and use pop up menus as well. However, this new functionality is a part of AWT, so it doesn't do a very good job integrating with Swing components.

Here's an example of a little clock that shows up in the system tray which was made using the SystemTray and TrayIcon classes in Java 6:

Java中的系统托盘时钟应用程序
(source: coobird.net )

Plain old Winforms would get my vote.

If you are familiar with Java you should have little difficulty using one of the managed languages to create a simple tray app with .NET.

Here is some advice on the correct way to create a tray app.

Be carefully with manged applications and Java here. Tray applications run all the time. So, if they are poorly written then they can use enough system resources to interfere with other things.

There is nothing wrong with manged code or Java in general, but it can be more difficult to keep managed or java apps frugal with memory, I/O and CPU time.

I'm saying this as a dev manger on the Windows perf team - we've seen lots and lots of very piggy tray applications. Yes, some are even windows or MSFT applications.

It may be a better approach to write a very small light weight tray app that launches a richer process when the user needs it. You can write your try app in simple C++ right on top of the low level Win32 APIs. If you don't want to use the Win32 APIs directly, you can use the Windows Template Library .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM