Here is a step-by-step procedure for minimizing an application to the system notification tray in XAML VB:
First, add a reference to the System.Windows.Forms namespace in your project.
Next, create a NotifyIcon object and set its properties. The NotifyIcon object represents the icon that will be displayed in the system notification tray.
Dim notifyIcon As New NotifyIcon()
notifyIcon.Icon = New System.Drawing.Icon("icon.ico")
notifyIcon.Visible = True
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
' Minimize to system notification tray
End If
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.Visible = False
notifyIcon.ShowBalloonTip(500)
End If
End Sub
Private Sub notifyIcon_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles notifyIcon.MouseDoubleClick
Me.Visible = True
Me.WindowState = FormWindowState.Normal
End Sub
With these steps, your application will be able to minimize to the system tray and restore when double-clicked.
Asked: 2022-09-03 11:00:00 +0000
Seen: 9 times
Last updated: Dec 02 '21