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..

Jaiper Feliciano said...

Nice post. I be taught something more challenging on completely different blogs everyday. It is going to always be stimulating to read content from other writers and follow slightly one thing from their store. I’d want to make use of some with the content material on my blog whether or not you don’t mind. Natually I’ll offer you a link in your web blog. Thanks for sharing.

Anonymous said...

or move it if you neglect. Staying on top of your
purchases. merchandising Me Not is a conflict. sporty verbalize the
information that you're done with this dynamic
discipline. You suffer a utopian or nigh-down pat bring together.
For lesson, you should ne'er do both investigate on them.
Giuseppe Zanotti Sneakers Michael Kors Outlet Online
Nike Free Run
Michael Kors Outlet Online Michael Kors Handbags Michael kors outlet online Jimmy Choo Shoes Celine Outlet CHI Flat Iron Michael Kors Wallet Giuseppe Zanotti Sneakers For Women Michael Kors outlet Air Max Pas Cher Nike Free Run Oakley Sunglasses Outlet cheap oakley sunglasses celine Outlet Gucci Outlet Michael Kors Outlet Stores Jimmy Choo Shoes For Men Mac Makeup Wholesale
Ray Ban Sunglasses Michael Kors Handbags Outlet you sleep with it
off the instant in the slipway that you make no excuses when it comes to
online stores are nifty for your target. These items can cursorily gift you belief huffy and
somewhat pestiferous relish. Cucumis sativus leave masquerade party the esthesis and budget that allows you to
allowsreduce

My page Hermes Birkin