实现窗口最小化后不在任务栏显示,而是在系统栏中以图标形式显示,如果在系统栏的图标上按下鼠标,则窗口恢复,代码如下(参考):
’先把NotifyIcon1.Visible设置为False,即不显示
Private Sub NotifyIcon1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDown
’按下鼠标事件,如果窗口状态为最小化
If Me.WindowState = FormWindowState.Minimized Then
’则恢复窗口状态为普通
Me.WindowState = FormWindowState.Normal
’让任务栏可见窗口
Me.ShowInTaskbar = True
’系统栏图标隐藏
NotifyIcon1.Visible = False
End If
End Sub
Private Sub MainForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
’当窗口大小改变时,如果窗口是最小化
If Me.WindowState = FormWindowState.Minimized Then
’系统栏图标显示
NotifyIcon1.Visible = True
’任务栏不显示窗口
Me.ShowInTaskbar = False
End If
End Sub

浙公网安备 33010602011771号