Step 1. Create a new project, select the Windows Forms Application and give it a name, for the purpose of this tutorial i decided to name my project, "MinimizeTray".
You must be registered to see links
Step 2. Add a button to your form.
You must be registered to see links
You must be registered to see links
Step 3. In the properties panel, change the text of the button to something more appropriate than "Button1". I decided to make mine say, Minimize to Tray (re-size the button if needed to fix the text)
You must be registered to see links
You must be registered to see links
Step 4. Add a notify icon to your form.
You must be registered to see links
You must be registered to see links
Step 5. Change the visible property on your notify icon to "False" from the default "True", we don't want it visible until we tell it to be!
You must be registered to see links
Step 6. Double click the button on the forum to switch from designer to code viewer/editor, and start the code of your button with the click event.
You must be registered to see links
Step 7. First you want to hide the form, and then show the notify icon. Use the following code.
Code:
' Anything with an apostrophe at the beginning in a line is a comment.
' The first part of the code tells the current form to hide, we use Me.Hide() since its calling upon itself
' If we wanted to hide a different form (ex. Form2) we would use the forms name instead. (ex. Form2.Hide())
Me.Hide()
' This next part tells the notify icon to be visible.
NotifyIcon1.Visible = True
You must be registered to see links
Step 8. Go back to the designer and double click on the notify icon control to open the code viewer/editor and start the code for your notify icon double click event.
You must be registered to see links
Step 9. In the declarations combobox change "MouseDoubleClick" to "MouseClick"
You must be registered to see links
Step 10. First you want to bring the form out of hiding, and then change the notify icon visibility back to "False". Use the following code.
Code:
' To show a form we use Me.Show() again if it were a different form we were calling on, we would use (ex. Form2.Show()) Me.Show()
' This next part tells the notify icon to be invisible again.
NotifyIcon1.Visible = False
You must be registered to see links
Compile and give yourself a pat on the back!
Thats how you do a tutorial.