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:

zhihow said...

thx for sharing

Anonymous said...

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

Anonymous said...

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

Anonymous said...

Thanks,very helpful.

Anonymous said...

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

Anonymous said...

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

Anonymous said...

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?

Anonymous said...

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

Anonymous said...

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

Anonymous said...

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

Anonymous said...

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.

Rittwick Banerjee said...

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

Anonymous said...

I liked the article, but some disagree

Audience Response System said...

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.

CPS Clicker said...

So happy to be here in your site.

SEO Specialist in the Philippines said...

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.

Bow Point Nursery said...

This seem informative!

My Deaf America said...

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

yanmaneee said...

air max 2019
off white clothing
coach outlet sale
goyard
nike air max 2017
air jordans
coach bags
yeezy boost 350
kyrie 4 shoes
air max 97

Anonymous said...

supreme outlet
kyrie shoes
supreme outlet
yeezy
fear of god essentials hoodie
russell westbrook shoes
bape clothing
yeezy
off white hoodie
golden goose sneakers