L
LineSupport
Hello,
I am a little confused over the behavior of a form with a NotifyIcon.
The property ShowInTasbar of the form is set to false. The NotifyIcon
does have an Icon set.
When I minimize the form, the Icon appears in the system tray as
expected. But, when I click on the icon the first time, the form
restores to a small window just above the Taskbar as if it had been
minimized.
A second mouse click on the Icon restores the form in its full glory.
The code below is complete. I created this simple test application
just to test the NotifyIcon behavior.
The behavior I would like is as follows.
1. Not visible in the Taskbar
2. Minimize hides the form.
3. An attempt to Close the form without password hides the form.
4. Click on the Icon restores the Form to previous location.
Public Class formTest
Private Sub formTest_FormClosing(ByVal sender As Object, ByVal e
As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If TextBox1.Text = "PASS" Then
e.Cancel = False
Else
e.Cancel = True
Me.WindowState = FormWindowState.Minimized
End If
End Sub
Private Sub formTest_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
NotifyIconX.Text = "Just_A_Icon :" & vbCr & "Double Click to
Activate."
End Sub
Private Sub formTest_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
If Me.WindowState = FormWindowState.Minimized Then
Hide()
End If
If Me.WindowState = FormWindowState.Maximized Then
Debug.Print("Showing")
Me.WindowState = FormWindowState.Normal
Show()
End If
End Sub
Private Sub NotifyIconX_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIconX.Click
Me.WindowState = FormWindowState.Normal
Show()
End Sub
End Class
Thanks,
I am a little confused over the behavior of a form with a NotifyIcon.
The property ShowInTasbar of the form is set to false. The NotifyIcon
does have an Icon set.
When I minimize the form, the Icon appears in the system tray as
expected. But, when I click on the icon the first time, the form
restores to a small window just above the Taskbar as if it had been
minimized.
A second mouse click on the Icon restores the form in its full glory.
The code below is complete. I created this simple test application
just to test the NotifyIcon behavior.
The behavior I would like is as follows.
1. Not visible in the Taskbar
2. Minimize hides the form.
3. An attempt to Close the form without password hides the form.
4. Click on the Icon restores the Form to previous location.
Public Class formTest
Private Sub formTest_FormClosing(ByVal sender As Object, ByVal e
As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If TextBox1.Text = "PASS" Then
e.Cancel = False
Else
e.Cancel = True
Me.WindowState = FormWindowState.Minimized
End If
End Sub
Private Sub formTest_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
NotifyIconX.Text = "Just_A_Icon :" & vbCr & "Double Click to
Activate."
End Sub
Private Sub formTest_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
If Me.WindowState = FormWindowState.Minimized Then
Hide()
End If
If Me.WindowState = FormWindowState.Maximized Then
Debug.Print("Showing")
Me.WindowState = FormWindowState.Normal
Show()
End If
End Sub
Private Sub NotifyIconX_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIconX.Click
Me.WindowState = FormWindowState.Normal
Show()
End Sub
End Class
Thanks,