[VB.NET]如何将图标放在系统托盘上

本文介绍如何使用VB.NET创建系统托盘图标,并实现窗口最小化至托盘及通过托盘图标重新打开窗口的功能。文章提供了具体的代码示例,包括如何响应窗口关闭事件、最小化事件以及托盘图标的点击事件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VB.NET源码-156个实用实例哦…… 如何将图标放在系统托盘上
如何将图标放在系统托盘上? 及单击最小化到系统托盘上,再单击系统托盘上的图标弹出窗体界面,请大虾指教,谢谢

__________________________________________________________________________
看这里吧,写得很清楚。
http://hi.baidu.com/winlt/blog/item/99056d277a390a03908f9d64.html
__________________________________________________________________________
加入一个NotifyIcon控件,然后

Dim boolClose As Boolean = False

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
NotifyIcon1.Visible = False
End Sub

'' 点击关闭时最小化到System Tray,而不关闭
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If boolClose = False Then
e.Cancel = True
Me.Visible = False
NotifyIcon1.Visible = True
End If
End Sub

'' 点击System Tray图标时显示主窗体
Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Visible = True
NotifyIcon1.Visible = False
End If
End Sub
__________________________________________________________________________
这样会退不出程序,要在菜单中和NotifyIcon的右键菜单中加入令boolClose为真然后关闭窗口的的项,使程序可以退出。
__________________________________________________________________________
好的,谢谢各位,成功了
__________________________________________________________________________
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值