添加一个notifyIcon控件
vb.net
Private Sub vbFormTest_Resize(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Resize
If WindowState = FormWindowState.Minimized Then
Me.Visible = False
Me.NotifyIcon1.Visible = True
End If
End Sub
Private Sub NotifyIcon1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles NotifyIcon1.Click
Me.Visible = True
NotifyIcon1.Visible = False
Me.WindowState = FormWindowState.Normal
End Sub
c#.net
//调整窗体大小的时候,如果是最小化,窗体不显示,在托盘中显示
private void Form1_Resize(object sender,EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1.Visible = true;
}
}
//如果点击托盘中的窗体图标,则窗体显示,托盘中的图标隐藏
private void notifyIcon1_Click(object sender,EventArgs e)
{
this.Visible = true;
this.notifyIcon1.Visible = false;
WindowState = FormWindowState.Normal; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。