让应用程序最小化到系统托盘点击按钮时? [英] Having the application minimize to the system tray when button is clicked?

查看:193
本文介绍了让应用程序最小化到系统托盘点击按钮时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何我有我自己的应用程序最小化到在WindowsXP / Vista的系统盘?

How can I have my application minimize itself to the system tray in WindowsXP/Vista?

我也在寻找一种方式,有消息显示自己当鼠标在图标上徘徊。是否有可能在弹出气球两行?

I'm also looking for a way to have a message display itself when the mouse is hovered on the icon. Is it possible to have two lines in the pop up balloon?

推荐答案

我假设你的意思是最小化到系统托盘,因为你有?谈到图标和消息气球

I assume you mean minimize to the System tray because you have talked about icons and message ballons?

下面的代码将成立一个托盘图标:

The following code will set up a tray icon:

private void SetUpTrayIcon()
{
    notifyIcon = new System.Windows.Forms.NotifyIcon();
    notifyIcon.BalloonTipText = "Ballon minimize text";
    notifyIcon.BalloonTipTitle = "Ballon minimize title";
    notifyIcon.Text = "Icon hover text";
    notifyIcon.Icon = new  System.Drawing.Icon(
               System.Reflection.Assembly.GetExecutingAssembly()
                   .GetManifestResourceStream("MyIcon.ico"));
    notifyIcon.Click += new EventHandler(HandlerToMaximiseOnClick);
}

要显示在任务栏中的图标(你可能想这样做的比如窗口状态改变事件,像做以下几点:(!NotifyIcon的= NULL)

To show the icon in the tray (you may want to do this on the window state change event for example, do something like the following:

if (notifyIcon != null)
{
    notifyIcon.Visible = true;
    notifyIcon.ShowBalloonTip(2000);
}


$ b $ :b

要显示在鼠标悬停气球要在鼠标移动的图标,上面可能使用相同的代码

To display a ballon on mouse hover you want to use the same code as above possibly in the mousemove for the icon.

请注意:ShowBalloonTip超载,如果你要在不同的点来改变消息。消息气球显示将尊重换行符例如Environment.NewLine可以添加到它

Note: ShowBalloonTip is overloaded if you want to change the message at different points. The message the balloon displays will respect newlines eg Environment.NewLine can be added to it.

这篇关于让应用程序最小化到系统托盘点击按钮时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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