Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi guys,

 

I got my app' to minimize to the tray ok that was easy enuff and I've got a doubleclick event for the trayicon to restore the form using windowstate.normal and this was all working fine.

 

Now I've added a couple of lines of code so that when the form is open form1.showintaskbar = true and trayicon.visible = false and then when the form gets minimized form1.showintaskbar = false and trayicon.visible = true.

 

The problem I'm having since I made these changes is that double clicking on the trayicon restores the app' but only to the taskbar and assumes that as being its 'normal' state. The only way I can see the form after that is to maximize it.

 

Can't find anything about this specific prob' on the forums or on the MSDN examples or the Forms FAQ.

 

Anyway here's the code...

 


Private Sub TrayIcon_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrayIcon.DoubleClick
       Me.ShowInTaskbar = True
       TrayIcon.Visible = False
       Me.WindowState = FormWindowState.Normal
       Me.Activate()
End Sub

Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
       If Me.WindowState = FormWindowState.Minimized Then
           Me.ShowInTaskbar = False
           TrayIcon.Visible = True
       End If
End Sub

 

Cheers,

Andy!

I'm getting the hang of this now... No really I am!
  • *Experts*
Posted
I don't see how one can be faster than the other... all either of them do is remove WS_VISIBLE from the list of window styles applied to the form.
Posted

Aah I see... no need for the showintaskbar at all. That will teach me to try and be clever :D.

 

Cheers VF!

I'm getting the hang of this now... No really I am!
Posted

TrayIcon is now called NotifyIcon.

 

There is actually a subtleish difference between the ShowInTaskbar and Visible methods. If you set Visible to false, then, when you Alt+Tab between applications, your application will not be in the list. With the ShowInTaskbar method, your application will still be there (although it turns out to be a "blank window" icon -- this seems like a bug...?).

 

I didn't have a problem with either method, though: you just have to make sure to reset the rest of the state (make it visible or whatever) before resizing the form.

  • 5 years later...
Posted

Hi guys,

 

i have a problem,

 

I have written the code exactly the same which you have posted.

the following is the ccode,

 

Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Resize

If Me.WindowState = FormWindowState.Minimized Then

Me.Hide()

'Me.ShowInTaskbar = False

TrayIcon.Visible = True

TrayIcon.Text = "Hide Me"

End If

End Sub

 

Private Sub TrayIcon_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TrayIcon.MouseDoubleClick

 

Me.ShowInTaskbar = True

Me.Show()

TrayIcon.Text = "Show Me"

Me.Enabled = True

Me.WindowState = FormWindowState.Normal

*******'Me.Activate()*****

 

End Sub

 

 

The Problem is i do not know where the activate method is there for the form.

and when i minimize the form, it is perfectly getting invisible and as well as from the taskbar too.

 

but i cannot see the icon in the System Tray. please help.

 

Thanks

Vish

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...