如何使Windows窗体.NET应用程序显示为托盘图标? [英] How to make a Windows Forms .NET application display as tray icon?

查看:272
本文介绍了如何使Windows窗体.NET应用程序显示为托盘图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要做什么让你的.NET应用程序显示在窗口的系统托盘中的图标?

What needs to be done to have your .NET application show up in Window's system tray as icon?

和你如何处理mousebutton点击所述图标?

And how do you handle mousebutton clicks on said icon?

推荐答案

首先,添加一个NotifyIcon控件到窗体。随后连线了通知图标做你想做的。

First, add a NotifyIcon control to the form. Then wire up the Notify Icon to do what you want.

如果你想让它隐藏到系统托盘上的减少,试试这个。

If you want it to hide to tray on minimize, try this.

Private Sub frmMain_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    If Me.WindowState = FormWindowState.Minimized Then
        Me.ShowInTaskbar = False
    Else
        Me.ShowInTaskbar = True
    End If
End Sub

Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
    Me.WindowState = FormWindowState.Normal
End Sub

我会偶尔使用气球文本,以通知用户 - 这是作为这样

I'll occasionally use the Balloon Text in order to notify a user - that is done as such

 Me.NotifyIcon1.ShowBalloonTip(3000, "This is a notification title!!", "This is notification text.", ToolTipIcon.Info)

这篇关于如何使Windows窗体.NET应用程序显示为托盘图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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