Click here to Skip to main content
Licence 
First Posted 9 May 2004
Views 40,464
Bookmarked 18 times

A Simple Program for Status Bar Notification using Whidbey

By | 9 May 2004 | Article
The NotifyIcon Component will display an icon in the status bar notification area, which you can use as notiification purpose to alert users that an action or event has occured.

Sample Image - StatusBar.jpg

Introduction


The NotifyIcon component will display an icon in the status bar notification area, which you can use as notification purpose to alert users that an action or event has occured. You can write code in the Click or DoubleClick event handler or any of the event handler you like to associate your application.

Steps to Create the NotifyIcon application

1. Start a new project and save as “NotifyIcon”.


2. Save the Form1.vb as frmNotifyIcon.vb

NotifyIcon project


3. Double click on the frmNotifyIcon.vb to load the form from the Solution Explorer bar.


4. Drag and Drop the Component NotifyIcon from the toolbox.


NotifyIcon Image 2

Note: Context Menu will be displayed on the bottom of the current form

NotifyIcon Image - 3

5. Make new menu items as shown below

Image 4 : NotifyIcon

6. Change the name of menu item as shown below:

mnuMicrosoftHome
mnuMicrosoftASPNet
mnuMicrosoftWindowsFormNet
mnuMSDN
mnuMSNBC
mnuMSN

7. Add a new procedure called SelectLink.

  Private Sub SelectLink(ByVal strMicrosoftWebSiteName As String)
 
        Dim strWebSiteName As String
 
        Try
 
            Select Case strDescription
                Case "mnuMicrosoftHome" : strWebSiteName = "<A href="http://www.microsoft.com/">http://www.microsoft.com/</A>"
                Case "mnuMicrosoftASPNet" : strWebSiteName = "<A href="http://www.asp.net/">http://www.asp.net/</A>"
                Case "mnuMicrosoftWindowsFormNet" : strWebSiteName = "<A href="http://www.windowsforms.net/">http://www.windowsforms.net/</A>"
                Case "mnuMSDN" : strWebSiteName = "<A href="http://www.msdn.microsoft.com/">http://www.msdn.microsoft.com/</A>"
                Case "mnuMSNBC" : strWebSiteName = "<A href="http://www.msnbc.com/">http://www.msnbc.com/</A>"
                Case "mnuMSN" : strWebSiteName = "<A href="http://www.msn.com/">http://www.msn.com/</A>"
            End Select
 
            ' Call the Process.Start method to open the default browser 
            ' with a URL:
            System.Diagnostics.Process.Start(strWebSiteName)
 
        Catch ex As Exception
            ' The error message
            Beep()
            MessageBox.Show("Unable to open link " & strDescription & " that was clicked.")
 
        End Try
    End Sub

7. Call the selectlink procedure in each click event of menu item.

    Private Sub mnuMicrosoftHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMicrosoftHome.Click
        SelectLinkClick(mnuMicrosoftHome.Text)
    End Sub
 
  Private Sub mnuMicrosoftASPNet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuMicrosoftASPNet.Click
        SelectLinkClick(mnuMicrosoftASPNet.Text)
    End Sub
 
    Private Sub mnuMicrosoftWindowsFormNet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuMicrosoftWindowsFormNet.Click
        SelectLinkClick(mnuMicrosoftWindowsFormNet.Text)
    End Sub
 
    Private Sub mnuMSDN_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuMSDN.Click
        SelectLinkClick(mnuMSDN.Text)
    End Sub
 
    Private Sub mnuMSN_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuMSN.Click
        SelectLinkClick(mnuMSN.Text)
    End Sub
 
    Private Sub mnuMSNBC_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuMSNBC.Click
        SelectLinkClick(mnuMSNBC.Text)
    End Sub

8. Add the NotifyIcon component from the toolbox.

Image 5 - NotifyIcon

9. Add the following lines of code in the Form_Load event.

Private Sub frmNotifyIcon_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     Me.Visible = False
     NotifyIcon1.Visible = True
End Sub

10. Rename the menu name ContextMenu1.

Image 6 - NotifyIcon

11. Make the project and see how it works!

StatusBar Output Image - 1/2

NotifyIcon - Output 2

Requirements

Microsoft Visual Studio.Whidbey Ver 8.0 Or
Microsoft Visual Studio.NET Professional or greater.
Windows 2000 or Windows XP.

Summary:

This is a small program, which will helps you to understand how the NotifyIcon component works. In VB 6.0, we have to do a lot of stuffs to get this icon. This easily simplifies in .NET.

If you need any suggestions or help, let me contact at benoyraj@yahoo.com

Thank you

Benoyraj

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Binoy R



United States United States

Member

Binoy is a software developer of Information Technology Division in Memphis,TN.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionQuestion Pinmembertimnboys10:49 21 Jan '10  
GeneralThis is VB.NET... PinmemberRay Hayes8:59 10 May '04  
GeneralRe: This is VB.NET... Pinmemberbenoyraj2:25 11 May '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 10 May 2004
Article Copyright 2004 by Binoy R
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid