I comment on my application quickly and then the problem:
I have two Forms, each of them has a button that opens the other and closes that one (changes form, go). The
Form1 has a
NotifyIcon for, in case of closing both windows, to reopen it. All this works well. The problem comes when I return from
Form1 , which creates another equal icon in the notification bar, there being two. If I go back to
Form1 nothing happens, but when I return to
Form1 I create another icon and so infinitely, only going from
I leave the code that I think affects this to see if you can help me out because I'm not able to see the problem.
Form2 button that returns to
Private Sub FTTA_Click(sender As Object, e As EventArgs) Handles FTTA.Click Dim goAlmacen As New FormAlmacen goAlmacen.Show() Me.Hide() End Sub
Private Sub FormAlmacen_Load(sender As Object, e As EventArgs) Handles MyBase.Load vIn.Select() Dim r As Rectangle = My.Computer.Screen.WorkingArea Location = New Point(r.Width - Width, r.Height - Height) vIn.Text = String.Empty vOUT.Text = String.Empty txt1.Text = String.Empty txt2.Text = String.Empty vNombre.Text = String.Empty End Sub Private Sub Vnotificación_MouseClick(sender As Object, e As MouseEventArgs) Handles Vnotificación.MouseClick vIn.Select() Me.Show() vIn.Text = String.Empty vOUT.Text = String.Empty txt1.Text = String.Empty txt2.Text = String.Empty vNombre.Text = String.Empty End Sub
Finally, in the design it is put in the following way, I do not know if it will have to see but just in case (I delete the parts of code that do not interest.)
Private Sub InitializeComponent() Me.Vnotificación = New System.Windows.Forms.NotifyIcon(Me.components) resources.ApplyResources(Me.Vnotificación, "Vnotificación") End Sub Friend WithEvents Vnotificación As NotifyIcon
Maybe there is some way to "kill" an icon and replace it with another if it exists or something like that, but I'm not able to do it. Any ideas?
Code of the button that leads from
Private Sub ButtonVolver_Click(sender As Object, e As EventArgs) Handles FATT.Click Dim goTrabajos As New FormFases goTrabajos.Show() Me.Hide() End Sub