我怎样才能让一个.NET Windows窗体只能运行在系统托盘中的应用程序? [英] How can I make a .NET Windows Forms application that only runs in the System Tray?

查看:251
本文介绍了我怎样才能让一个.NET Windows窗体只能运行在系统托盘中的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么我需要做的,使一个 Windows窗体应用程序运行在系统托盘?

不是一个应用程序,可以最小化到托盘,而是一个只存在于盘内,无非就是一个图标,工具提示和右键单击菜单。

解决方案

使用的NotifyIcon的基本答案是正确的,但像很多事情.NET,还有很多参与做的微妙之处权。由布拉德·提到的教程提供了良好的步行通过的非常基本的,但并没有解决任何这些:

  • 是否关闭应用程序从系统托盘中正确关闭所有打开的子窗体?
  • 应用程序是否强制实施本身只有一个实例可以运行(适用于大多数,但不是全部,托盘的应用程序)?
  • 如何。如果需要打开WPF的子窗口以及WinForms的子窗口。
  • 如何支持动态上下文菜单。
  • 在该标准的NotifyIcon存在的WinForms空间;我可以做一个纯粹的WPF的解决方案? (是的,你可以!)

我刚刚发表了关于Simple-Talk.com文章称,很详细解决这些问题,并能提供一个托盘应用程序框架,你可以立即投入使用,再加上一个完整的,真实世界的示例应用程序,以显示一切在实践中。请参阅<一href="http://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/">Creating托盘应用.NET:实用指南,公布2010年11月

What do I need to do to make a Windows Forms application run in the System Tray?

Not an application that can minimize to the tray, but one that exists only in the tray, with nothing more than an icon, tool tip, and "right click" menu.

解决方案

The basic answer of using a NotifyIcon is correct but, like many things .NET, there are a host of subtleties involved in doing it right. The tutorial mentioned by Brad gives a good walk-through of the very basics, but does not address any of these:

  • Does closing the application from the system tray properly close any open child forms?
  • Does the application enforce that only one instance of itself may run (applicable to most, though not all, tray apps) ?
  • How to open WPF child windows as well as WinForms child windows, if desired.
  • How to support dynamic context menus.
  • The standard NotifyIcon exists in WinForms space; can I do a pure WPF solution? (Yes you can!)

I just had an article published on Simple-Talk.com that addresses these points and more in great detail, providing a tray application framework that you can put to use immediately, plus a complete, real-world example application to show everything in practice. See Creating Tray Applications in .NET: A Practical Guide, published November, 2010.

这篇关于我怎样才能让一个.NET Windows窗体只能运行在系统托盘中的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆