VB.NET 2005 - How do I add my program as an icon in the bottom right of the taskbar?

VB.NET 2005 - How do I add my program as an icon in the bottom right of the taskbar?

When I minimize my application I don't want to be in the task area but instead in the tray on the bottom right?

Is there a way to do this using an object in the framework or do I have to resort to the API?
HepenAsked:
Who is Participating?
 
jrschererCEOCommented:
First, give it an icon to make it visible in your tray. Also give it a text.

then add the two following event handler to your form:

    ' this will make the NotifyIcon visible when your form is minimized
    Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
        NotifyIcon1.Visible = (Me.WindowState = FormWindowState.Minimized)
    End Sub

    ' this will restore the window when you double-click the NotyfyIcon
    Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
        Me.WindowState = FormWindowState.Normal
    End Sub

You may also add single click event handler and context menues

Jack.net
0
 
jrschererCEOCommented:
Hi Hepen,
I think you are looking for the functionality of the control NotifyIcon. This is a standard control in your ToolBar.

Regards, Jack.net
0
 
HepenAuthor Commented:
I added it to my form. How do I use it? When I minimize my applicaiton I Just want it to go away and only remain in the bottom right corner then when I double click it or single click it, it will bring my application back
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Set the Visible property of the NotifyIcon to False.

Public Class Form1

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        If Me.WindowState = FormWindowState.Minimized Then
            NotifyIcon1.Visible = True
            Me.Hide()
        End If
    End Sub

    Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
        Me.Show()
        Me.WindowState = FormWindowState.Normal
        NotifyIcon1.Visible = False
    End Sub

End Class
0
 
jrschererCEOCommented:
Idle Mind,
You are right the Notify Icon visibility should be false at the start.
Question: why would you use Me.Show and Me.Hide, since these functions are intrinsic in the FormWindowState?
Jack.net (with highest respect of your competence)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
@jrscherer...

The authors second statement was:

    "When I minimize my application I don't want to be in the task area but instead in the tray on the bottom right?"

I use Me.Hide to make the form disappear from the taskbar.  Your code leves the forms entry in the taskbar.

=)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.