Problems Showing Main Form after Hide

J

jp2group

I have a Main Form that hides in the Task Bar Tray as an Icon until
one of the Tray Icon's Menu Items is selected. (think of your
antivirus program running there)

The program starts up fine and shows the main form fine, but once I
tell it to hide, it does not want to show back up later.

What could my problem be?

Here is my code:

Public Sub ShowMe(ByVal val As Boolean)
TopMost = False
If (val = True) Then
WindowState = FormWindowState.Normal
Show()
ShowInTaskbar = True
TopMost = True
ElseIf (val = False) Then
WindowState = FormWindowState.Minimized
Hide()
ShowInTaskbar = False
End If
Refresh()
Application.DoEvents()
End Sub
 
L

Lloyd Sheen

jp2group said:
I have a Main Form that hides in the Task Bar Tray as an Icon until
one of the Tray Icon's Menu Items is selected. (think of your
antivirus program running there)

The program starts up fine and shows the main form fine, but once I
tell it to hide, it does not want to show back up later.

What could my problem be?

Here is my code:

Public Sub ShowMe(ByVal val As Boolean)
TopMost = False
If (val = True) Then
WindowState = FormWindowState.Normal
Show()
ShowInTaskbar = True
TopMost = True
ElseIf (val = False) Then
WindowState = FormWindowState.Minimized
Hide()
ShowInTaskbar = False
End If
Refresh()
Application.DoEvents()
End Sub


This is code I use

Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIcon1.DoubleClick
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Maximized
Me.NotifyIcon1.Visible = False
End If
Me.Show()
Me.Activate()
End Sub

Hope this helps
LS
 
J

Just_a_fan

In case your form is not intended to be maximized, which is somewhat
rare, in my experience:

Private Sub NotifyIcon_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIcon.DoubleClick
Me.Show()
Application.DoEvents()
Me.WindowState = FormWindowState.Normal
Me.Focus()
End Sub

Using the code, below, maximizes the form. Changing "maximize" to
"normal" also has a problem of leaving the form a small, unusable thing
down in the corner.

The DoEvents, above, is probably redundant.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top