Click here to Skip to main content
Click here to Skip to main content

TaskbarNotifier, a skinnable MSN Messenger-like popup in C# and now in VB.NET too

, 30 Mar 2003 Public Domain
Rate this:
Please Sign up or sign in to vote.
The TaskbarNotifier class allows to display an MSN Messenger-like animated popup with a skinned background
<LINK href="global.css" type=text/css rel=stylesheet>


Since I am learning C#, I thought it would be helpful for me to port my C++ CTaskbarNotifier class ([ ^])

As a result, I coded a MSN Messenger-like skinnable popup, with a close button which looks almost like Microsoft's one (with the associated skin).

The TaskbarNotifier class inherits from System.Windows.Forms.Form and adds a few methods to it.


The MSN messenger like popup supports:

  • A custom transparent bitmap background
  • A skinnable 3-State close button
  • A clickable title text
  • A clickable content text
  • A selection rectangle
  • Custom fonts and colors for the different states of the text (normal/hover)
  • Animation speed parameters


This class is stand alone and doesn't need any particular libraries except .NET default ones. It runs in managed code and hence should be portable.

How to use the class

  • First of all, copy TaskbarNotifier.cs in your project directory.
  • Add on the top of your source code the directive:
    using CustomUIControls;
  • Add a member variable in your class:
    TaskbarNotifier taskbarNotifier;
  • In your constructor add the following lines:
    taskbarNotifier=new TaskbarNotifier();
            Color.FromArgb(255,0,255),new Point(127,8));
    taskbarNotifier.TitleRectangle=new Rectangle(40,9,70,25);
    taskbarNotifier.ContentRectangle=new Rectangle(8,41,133,68);
    taskbarNotifier.TitleClick+=new EventHandler(TitleClick);
    taskbarNotifier.ContentClick+=new EventHandler(ContentClick);
    taskbarNotifier.CloseClick+=new EventHandler(CloseClick);


        Color.FromArgb(255,0,255),new Point(127,8));

    The first line sets the background bitmap skin and transparency color (must be present), and the second line sets the 3-State close button with its transparency color and its location on the window (this line is optional if you don't want a close button).

    taskbarNotifier.TitleRectangle=new Rectangle(40,9,70,25);
    taskbarNotifier.ContentRectangle=new Rectangle(8,41,133,68);

    These two lines allow us to define the rectangles in which will be displayed, the title and content texts.

    taskbarNotifier.TitleClick+=new EventHandler(OnTitleClick);
    taskbarNotifier.ContentClick+=new EventHandler(OnContentClick);
    taskbarNotifier.CloseClick+=new EventHandler(OnCloseClick);

    These 3 lines allow us to intercept events on the popup such as title/content or close button have been clicked

  • Then we are done, we just need to call:


    This will show the popup animation with the showing/visible/hiding animations time set as 500ms/3000ms/500ms.

You can play with a few properties:

  • Title, content fonts and colors
  • Ability to click or not on the title/content/close button
  • You can disable the focus rect
  • ... (see below for more details)

Class documentation


void Show(string strTitle, string strContent, int nTimeToShow, 
                                            int nTimeToStay, int nTimeToHide)

Displays the popup for a certain amount of time.


  • strTitle: The string which will be shown as the title of the popup
  • strContent: The string which will be shown as the content of the popup
  • nTimeToShow: Duration of the showing animation (in milliseconds)
  • nTimeToStay: Duration of the visible state before collapsing (in milliseconds)
  • nTimeToHide: Duration of the hiding animation (in milliseconds)
void Hide()

Forces the popup to hide.

void SetBackgroundBitmap(string strFilename, Color transparencyColor)

Sets the background bitmap and its transparency color.


  • strFilename: Path of the background bitmap on the disk
  • transparencyColor: Color of the bitmap which won't be visible
void SetBackgroundBitmap(Image image, Color transparencyColor)

Sets the background bitmap and its transparency color.


  • image: Background bitmap
  • transparencyColor: Color of the bitmap which won't be visible
      void SetCloseBitmap(string strFilename, 
                  Color transparencyColor, Point position)

      Sets the 3-State close button bitmap, its transparency color and its coordinates.


      • strFilename: Path of the 3-state close button bitmap on the disk (width must be a multiple of 3)
      • transparencyColor: Color of the bitmap which won't be visible
      • position: Location of the close button on the popup
      void SetCloseBitmap(Image image, Color transparencyColor, Point position)

      Sets the 3-State close button bitmap, its transparency color and its coordinates.


      • image: Image/Bitmap object which represents the 3-state close button bitmap (width must be a multiple of 3)
      • transparencyColor: Color of the bitmap which won't be visible
      • position: Location of the close button on the popup


      string TitleText (get/set)
      string ContentText (get/set)
      TaskbarStates TaskbarState (get)
      Color NormalTitleColor (get/set)
      Color HoverTitleColor (get/set)
      Color NormalContentColor (get/set)
      Color HoverContentColor (get/set)
      Font NormalTitleFont (get/set)
      Font HoverTitleFont (get/set)
      Font NormalContentFont (get/set)
      Font HoverContentFont (get/set)
      Rectangle TitleRectangle (get/set) //must be defined before calling show())
      Rectangle ContentRectangle (get/set) //must be defined before calling show())
      bool TitleClickable (get/set) (default = false);
      bool ContentClickable (get/set) (default = true);
      bool CloseClickable (get/set) (default = true);
      bool EnableSelectionRectangle (get/set) (default = true);


      event EventHandler CloseClick
      event EventHandler TitleClick
      event EventHandler ContentClick

      Technical issues

      The popup is skinned using a region generated dynamically from a bitmap and a transparency color:

      protected Region BitmapToRegion(Bitmap bitmap, Color transparencyColor)
          if (bitmap == null)
              throw new ArgumentNullException("Bitmap", "Bitmap cannot be null!");
          int height = bitmap.Height;
          int width = bitmap.Width;
          GraphicsPath path = new GraphicsPath();
          for (int j=0; j<height; j++ )
              for (int i=0; i<width; i++)
                  if (bitmap.GetPixel(i, j) == transparencyColor)
                  int x0 = i;
                  while ((i < width) && 
                          (bitmap.GetPixel(i, j) != transparencyColor))
                  path.AddRectangle(new Rectangle(x0, j, i-x0, 1));
          Region region = new Region(path);
          return region;

      The refresh() of the popup is done using the double buffering technique to avoid flickering:

      protected override void OnPaintBackground(PaintEventArgs pea)
          Graphics grfx = pea.Graphics;
          grfx.PageUnit = GraphicsUnit.Pixel;
          Graphics offScreenGraphics;
          Bitmap offscreenBitmap;
          offscreenBitmap = new Bitmap(BackgroundBitmap.Width, 
          offScreenGraphics = Graphics.FromImage(offscreenBitmap);
          if (BackgroundBitmap != null)
                  0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
          grfx.DrawImage(offscreenBitmap, 0, 0);


      Since I wanted to keep only managed code, I used the Screen.GetWorkingArea(WorkAreaRectangle) function instead of using unmanaged code to get the taskbar position. As a result, I made the popup always appear at the bottom of WorkAreaRectangle whichever position the taskbar has.

      I didn't find any C# managed equivalent to the Win32 function ShowWindow(SW_SHOWNOACTIVATE) to make the popup, not steal the focus of the active window.


      • 01 April 2003: Small bug fix in the OnMouseUp handler.
      • 11 January 2003: Patrick Vanden Driessche updated both the C# and VB.NET versions:
        • The popup now doesn't close automatically when the mouse is still over it
        • The popup is shown again when it was disappearing and the mouse comes over it
        • A few other bugs have been corrected.
      • 10 January 2003: A port of TaskbarNotifier has been done by Patrick Vanden Driessche in VB.NET
      • 05 December 2002: The popup is now shown using the Win32 function ShowWindow(SW_SHOWNOACTIVATE), to prevent the popup from stealing the focus.


      I hope this code will be useful to you. If you have suggestions to enhance this class functionalities, please post a comment.

    • License

      This article, along with any associated source code and files, is licensed under A Public Domain dedication


      About the Author

      John O'Byrne
      Web Developer
      United States United States
      I live in Santa Clara CA and work as a software engineer for SAP Business Objects.
      My areas of expertise are user interface developments in Eclipse RCP / SWT / Draw 2D and C#

      Comments and Discussions

      QuestionWhere is the Missing Resource file for TaskBarNotifier.vb? Pinmembertimnboys27-Feb-10 8:59 
      AnswerRe: Where is the Missing Resource file for TaskBarNotifier.vb? Pinmembermarcodimarco28-Feb-10 23:23 
      GeneralTrigger closing on event Pinmembermarcodimarco25-Feb-10 22:41 
      GeneralRe: Trigger closing on event Pinmembermarcodimarco25-Feb-10 23:25 
      GeneralRe: Trigger closing on event Pinmemberleechangjun29-Mar-11 23:09 
      GeneralInclude in project? [modified] Pinmembermarcodimarco25-Feb-10 0:46 
      Generalpropage message through network PinmemberTrumanChua5-Feb-10 7:01 
      QuestionText Alignment of strContent Pinmemberflaurita19-Nov-09 6:04 
      GeneralEvents won't fire Pinmembernowh3r32h1d330-Oct-09 0:03 
      GeneralNotifier do not appear if client code is on a class library o console project PinmemberFrancesco Randazzo14-Oct-09 6:08 
      GeneralRe: Notifier do not appear if client code is on a class library o console project Pinmemberallentranks9-Dec-09 22:43 
      Generalproperty no found "Skin.bmp" VC# Express PinmemberDaniel Garzon7-Oct-09 13:52 
      QuestionProblem with Win7 Pinmemberbzyy1115-Sep-09 0:26 
      AnswerRe: Problem with Win7 Pinmemberbzyy1115-Sep-09 2:20 
      GeneralRe: Problem with Win7 Pinmembersee_seA5-Oct-09 6:08 
      GeneralRe: Problem with Win7 PinmemberEwinz8724-Feb-10 11:27 
      GeneralRe: Problem with Win7 PinmemberMember 698445427-Feb-10 20:28 
      GeneralRe: Problem with Win7 PinmemberEwinz8727-Feb-10 20:37 
      GeneralRe: Problem with Win7 PinmemberSyle1-Mar-10 0:17 
      GeneralRe: Problem with Win7 Pinmemberphotoevents12-Dec-10 7:07 
      GeneralRe: Problem with Win7 Pinmemberpennidren15-Sep-10 18:45 
      QuestionProblems with Vista? PinmemberLegoMindstorms25-Aug-09 7:39 
      GeneralIs there a way to make the edges smooth PinmemberMuhammad Ahmed10-Aug-09 7:16 
      GeneralLicense Pinmembertknman070026-Jul-09 12:13 
      GeneralThanx! Pinmemberjanniebun20-Jul-09 7:31 
      GeneralC++ version and Pinmembertipiak0728-Jun-09 9:55 
      QuestionHow to make the pop up a scheduled one PinmemberYeshwanthhv16-Jun-09 0:28 
      GeneralVery nice example PinmemberMember 223440129-May-09 11:53 
      GeneralReally terrific, Thanks! PinmemberJamie Simon24-Apr-09 8:26 
      Generalmissing resource file Pinmemberottilia4-Apr-09 6:47 
      GeneralASP.NET PinmemberSiphiwe25-Mar-09 2:37 
      GeneralVB 2005 skin.bmp Pinmemberroscael25-Feb-09 18:16 
      GeneralRe: VB 2005 skin.bmp Pinmemberklemmax26-Feb-09 5:36 
      GeneralRe: VB 2005 skin.bmp Pinmemberroscael26-Feb-09 7:26 
      GeneralFocus stealing woes Pinmemberr_hyde24-Feb-09 1:54 
      GeneralRe: Focus stealing woes [modified] Pinmemberr_hyde25-Feb-09 17:20 
      GeneralRe: Focus stealing woes PinmemberJosh Powers27-Feb-09 9:04 
      GeneralRe: Focus stealing woes [modified] Pinmemberr_hyde28-Feb-09 17:25 
      AnswerRe: Focus stealing woes PinmembernraMartin10-Feb-10 3:48 
      QuestionUse in VB.NET and Visual Studio 2008 Pinmemberitmanager881516-Feb-09 13:38 
      GeneralDisplay HTML or web page PinmemberRiceRocket29-Jan-09 10:42 
      Questionskin problem(C#) Pinmemberpicaleo26-Jan-09 17:02 
      AnswerRe: skin problem(C#) Pinmemberkaranme20-Feb-09 18:59 
      Questionhow to spread on multiple lines ? Pinmemberalmasih21-Jan-09 20:48 
      GeneralTransparent Layers look here!! Pinmembernewspicy18-Jan-09 5:29 
      Questionwhat if I use Window form to display taskbar notification that is the popup? PinmemberMember 444931811-Jan-09 19:45 
      Questionabout skin file Pinmembersahahima5-Jan-09 1:25 
      AnswerRe: about skin file PinmemberSchuege5-Jan-09 23:53 
      GeneralRe: about skin file Pinmembersahahima11-Jan-09 20:13 
      GeneralDrop Shadow around image PinmemberSchuege23-Dec-08 5:43 

      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.

      | Advertise | Privacy | Terms of Use | Mobile
      Web03 | 2.8.150224.1 | Last Updated 31 Mar 2003
      Article Copyright 2002 by John O'Byrne
      Everything else Copyright © CodeProject, 1999-2015
      Layout: fixed | fluid