Click here to Skip to main content
6,594,932 members and growing! (14,961 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » Custom Controls     Intermediate License: The GNU Lesser General Public License

Notification Bar

By Cory Borrow

A small and easy to use notification bar like that found in IE6+ and Firefox web browsers.
C# (C# 2.0), Windows (Win2K, WinXP, Win2003, Vista), .NET (.NET 2.0, Mono), Linux, Dev
Posted:3 Jun 2008
Updated:27 Jul 2008
Views:18,655
Bookmarked:107 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
31 votes for this article.
Popularity: 6.12 Rating: 4.10 out of 5
1 vote, 3.2%
1
3 votes, 9.7%
2
3 votes, 9.7%
3
10 votes, 32.3%
4
14 votes, 45.2%
5

InfoBar03_Normal.png

snapshot1.png

Introduction

The NotificationBar gives you an easy to use control that can replace message boxes / pop up boxes where they are not really needed. When the need arises to display a small amount of information without distracting users with pop ups, this would be a solution worth checking out.

Anyone who has used IE6+ on Win XP SP2+ knows about those Information / Notification bars you get when trying to download a file etc. That is what I have brought here today. A small, completely C# version of that control.

Current Features

  • Fast
  • Works on .NET and Mono
  • Can be used in commercial projects
  • Can flash control any number of times
  • Can use animation when showing and hiding the control
  • Can play sound when shown
  • Automatic word-wrap

Using the code

This control is very easy to use.

The classes and methods included in this library are listed below.

NotificationBar

Extending the Control class, the NotificationBar class is the only class in the library and houses the control.

  • OnClickMenuStrip
  • Sets the ContextMenuStrip seen when the control is clicked.

  • SmallImageList
  • Sets the ImageList used for displaying an image on the far left side of the control.

  • ImageIndex
  • Sets the image index of an image in the SmallImageList to be used in the control.

  • NotificationBar
  • The class constructor method.

  • DrawText
  • Draws the text seen on the control.

  • DrawCloseButton
  • Draws the close button seen on the far right side of the control.

Overridden methods and properties where left out of the list above.

Using the control is as easy as this:

//Add the using statement for the control's namespace
using WinComponents.Controls; 
//Then add the control your font, text, and anything else.
NotificationBar infoBar = new NotificationBar ();
infoBar.Name = "informationBar1";
infoBar.Size = new Size(100, 20);
infoBar.Dock = DockStyle.Top;
infoBar.Font = new Font(FontFamily.GenericSansSerif, 8.25f);
infoBar.Text = "Hello, here is some info!";
infoBar.Show();  
//Adding a pop-up menu or an image is as simple as
infoBar.OnClickMenuStrip = contextMenuStrip1;
infoBar.SmallImageList = imageList1;
infoBar.ImageIndex = 2;

These are the results you should get:

Normal view of information bar with short string:

InfoBar03_Normal.png

Hovered view of information bar with short string:

InfoBar03_Hover.png

And finally, the normal and hovered states with a longer string:

InfoBar04_Normal.png

InfoBar04_Hover.png

History

June 04, 2008 - Version 1.0.0 released

June 04, 2008 - Version 1.0.1 released

  • Changed the location of the close button.
  • Fixed the issue of image not changing after setting a new index.

July 02, 2008 - Version 1.0.2 released

  • Tested and works on Mono.
  • Renamed control to NotificationBar.
  • Added ability to flash control.
  • Added ability to play notification sound when control is shown.
  • Added designer support for property values.

July 27, 2008 - Version 1.0.4 released

  • Updated to where text color changes with background.
  • Added ability to animate showing and hiding the control.
  • Added screenshot of control working in Linux using Mono.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License

About the Author

Cory Borrow


Member
Started programming in about 2002 with Liberty BASIC,
afterwards moved to Visual BASIC and then PHP.
Now I enjoy writing software in C# as well as C/C++.
Location: United States United States

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
QuestionSame thing in Internet Explorer Pinmember101623:58 18 Feb '09  
NewsNotification Bar PinmemberMember 29883055:34 24 Nov '08  
GeneralDemo Project Pinmemberinetfly1233:13 3 Jul '08  
AnswerRe: Demo Project PinmemberCory Borrow5:55 3 Jul '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Jul 2008
Editor: Smitha Vijayan
Copyright 2008 by Cory Borrow
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project