VB.net return form not showing

I am currently using VB.Net 2008.
The Make One Installed Application checkbox is checked in the project.

The application works by hiding the form when the form is minimized.

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    If Me.WindowState = FormWindowState.Minimized Then
        Me.Hide()
    End If
End Sub

      

When the corresponding menu item is clicked in the notification, the form should show itself again.

     Private Sub ShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _  
                         Handles ShowToolStripMenuItem.Click
            Me.Show()
            Me.WindowState = FormWindowState.Normal
       End Sub  

      

This works great as long as the user doesn't try to open the same application while the form is minimized. When this happens, the application will block a new instance of the application that the user is trying to open as expected, however, when the user then displays the form from the notifyicon menu, it seemingly opens (it displays the form in the taskbar), but the window is not displayed.

At this point, the window can be maximized and works as intended, but using the restore button, the window will not be drawn, but will still be displayed on the taskbar.

If any help can be provided regarding how to properly restore the shape from underneath it would be very helpful.

Thank you in advance

+2


source to share


1 answer


Just a few suggestions ...

Instead of using Hide () and Show (), could you use the ShowInTaskbar property of the form?



Set to false where you are using Hide () and true where you are currently using Show () and see if it doesn't matter.

Or perhaps set WindowState to Normal before calling Show ().

0


source







All Articles