Just made a simple application that sits in the tasktray. It shows the PC name, IPV4 address, and Domain. I made it so that when a user closes the application it only closes to the tray unless EXIT is selected from the contextmenustrip. It worked totally fine. Then I added some code to try something and it didn't offer much so I removed it. Once removed the application stopped minimizing to the tray. It makes no sense because it's exactly as the code was prior. And the maxmimize button is supposed to be disabled.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Obtain Hostname and assign to label
strHostname = System.Net.Dns.GetHostName()
lblHostname.Text = strHostname.ToString
'Obtain IP Address and assign to label
Dim ipHostEntry = Dns.GetHostEntry(Dns.GetHostName)
Dim strIpAddress = ipHostEntry.AddressList.FirstOrDefault(Function(ip) ip.AddressFamily = AddressFamily.InterNetwork)
If strIpAddress IsNot Nothing Then
strIpAddress.ToString()
Else
lblIP.Text = "No IPV4 Address could be retrieved"
End If
lblIP.Text = strIpAddress.ToString
'Obtain Domain and assign to label
strDomain = Environment.UserDomainName
lblDomain.Text = strDomain.ToString
End Sub
Private Sub form1_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
'This checks to see if the form was closed by the MENU (Boolean = True)
' or if the user selected "X" which will minimize to task tray
'This is needed because X cannot be disabled without losing Minimize function
If BoolClose = False Then
e.Cancel = True
WindowState = FormWindowState.Minimized
Else
End
End If
End Sub
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
WindowState = FormWindowState.Normal
End Sub
Private Sub NotifyIcon1_MouseClick(sender As Object, e As MouseEventArgs) Handles NotifyIcon1.MouseClick
WindowState = FormWindowState.Normal
End Sub
I think you have your form's ShowInTaskBar
Property set to false
. But this will show you app in the taskbar and not in the system tray. Maybe this helps you.