2009-10-29

Show and Hide Windows Form in System Tray

How to show and hide your form in windows system tray.

1. Add NotifyIcon class in your project (System.Windows.Forms.NotifyIcon) and drag it into form.



2. Change NotifyIcon properties.
BalloonTipIcon = Info
BalloonTipText = Running
Change Icon
Text = Running Your Program
Visible = True




3. Add code in Event Form1_Resize.

Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Resize
' If minimize form that will show in system tray.
If System.Windows.Forms.FormWindowState.Minimized = WindowState Then
sysMonTray.ShowBalloonTip(5, "Running", "Running Your Program", ToolTipIcon.Info)
Me.Hide()
End If
End Sub


4. Add code in Event NotifyIcon_Click to hide and show form.

Private Sub sysMonTray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles sysMonTray.Click

If Me.Visible Then
Me.Hide()
Else
Me.Show()
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Normal
Me.StartPosition = FormStartPosition.CenterScreen
End If

End Sub


20 comments:

  1. Good fill someone in on and this mail helped me alot in my college assignement. Gratefulness you as your information.

    ReplyDelete
  2. Hi man. I am only I start to study c programs
    c program tutorial.
    I have visited a site http://program.v3host.be/?cat=204.
    Much to our regret I have very little found out about it.
    You can probably tell to me a good site about programming c.
    I will be very glad.
    Thansk

    ReplyDelete
  3. Thanks,very helpful.

    ReplyDelete
  4. It was extremely interesting for me to read the article. Thanks the author for it. I like such themes and anything that is connected to them. I definitely want to read more soon.

    Hilary Hakkinen
    find escorts

    ReplyDelete
  5. Rather nice blog you've got here. Thanks the author for it. I like such themes and everything connected to this matter. I definitely want to read more on that blog soon.

    Joan Smith
    kiev escort

    ReplyDelete
  6. I definitely want to read a bit more on this blog soon. BTW, pretty good design your site has, but how about changing it every few months?

    ReplyDelete
  7. It is extremely interesting for me to read that article. Thanx for it. I like such topics and everything connected to this matter. I would like to read more on that blog soon.
    What do you think about changing it from time to time?

    Julia Smith
    escort monaco baviera

    ReplyDelete
  8. Pretty interesting place you've got here. Thanks for it. I like such topics and everything connected to them. I definitely want to read more soon.

    Julia Hakkinen
    accompagnatrice milano accompagnatrice escort girl milano

    ReplyDelete
  9. Pretty cool site you've got here. Thanks for it. I like such themes and anything connected to this matter. I definitely want to read more on that blog soon.

    Joan Swenson
    block mobile phone signal

    ReplyDelete
  10. Why do you only toggle between 1-2, instead of all 3. Your code is pointless without #3.

    1. Hide the window
    2. Show the window
    3. If the window is behind other windows, move it to front.

    ReplyDelete
  11. First of all I'ld like to thank you for awesome blog & posts. carry on, its really a nice job for those of us who are learning .NET for a few months or weeks.
    Once again thank you,
    Rittwick Banerjee, Kolkata, West Bengal, India

    ReplyDelete
  12. I liked the article, but some disagree

    ReplyDelete
  13. I have come to my conclusion that your post head “ ” is one of the neatest, the only thing is the beginning of your post isn’t loading.

    ReplyDelete
  14. So happy to be here in your site.

    ReplyDelete
  15. Hi. I wanted to drop you a quick word to express my thanks. Ive been following your weblog for a month or so and have picked up a ton of excellent info and loved the tactic youve structured your site. I am trying to run my very own weblog nonetheless I believe its too normal and I need to deal with a lot of smaller topics. Being all things to all folks is not all that its cracked up to be.

    ReplyDelete
  16. It's good to read this information from your post. You have an interesting way of drawing people in. Keep up the good works..

    ReplyDelete

Thanks for your comment.