Clément
Clément

Reputation: 12937

Hide a form to the system tray

I'm posting this here since it took a lot of time for me to understand how the whole thing works when trying to hide a form in the systray.

My question basically was: How can I hide a windows form running operations to the system tray?

CFP.

Upvotes: 2

Views: 3626

Answers (1)

Clément
Clément

Reputation: 12937

The first step is to show the from that you will need to hide. Make sure you don't make it Modal.

Dim F as New MyForm
Form.Show()

Then, create a notification icon, and make associate the following with its click function:

Me.Visible = Not Me.Visible

Careful though. If you first showed the form using ShowDialog, then setting Visible = False will close the form and destroy it (which can get nasty if you were using a separate thread which communicated with the form, for example).

Upvotes: 1

Related Questions