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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
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
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)
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
@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.

=)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.