Windows 7-style Notification Area Applications in WPF: Recap & Sample

View source on GitHub.

Over the past month I’ve looked at how to implement a Windows 7-style notification area application in WPF.

I covered 6 different topics:

As promised, I’ve put together a small sample project to illustrate all this code working together (with some added polish):

NotifyIconSample.7z
42,775 bytes; SHA-1: 513E998F4CCFC8C5BB6CA9F8001DA204C80FDF3A

The code has a good level of documentation, but I recommend you read the above posts to understand the ideas behind it.

8 thoughts on “Windows 7-style Notification Area Applications in WPF: Recap & Sample”

  1. Good article… Thank you
    However, the application has some issues when we use an external monitor. When the monitor is connected, the application is unable to get the mouse click on the Quppa link. This only happens in this application.
    This is using a touch screen PC connected to an external monitor via HDMI. The change in resolution seems to be the problem
    Admin edit: this is possibly a bug related to touch input and WPF.

  2. Do you happen to have any VB.net examples of removing the border resize and finding the icon position?

  3. I’ve got this working in VB now, do you know if there is a way of telling whether the icon is on the taskbar or in the hidden icon box? The Microsoft design guidelines say icons on the taskbar should use muted colours so I’d like to swap the icon depending on where it is.

  4. @Nicky: The system icons don’t change appearance depending on their location, but if you want to do that, it should be easy enough.
    There’s a function called IsNotifyIconInFlyOut() (with two overloads) in WindowPositioning.cs that does what you need. It just checks whether the icon’s bounding rectangle is outside the taskbar’s bounding rectangle (though it always returns false if the fly-out is closed).

  5. Awesome posts and excellent code, it seems like this would be a more common pattern and should be easier to implement than it is…
    Do you know how one would go about adding the gradient + link at the bottom of the form in a way that would be consistent with the system styles?
    I’m getting stuck on this.

    1. Thanks for the feedback. I too wish this were easier to implement.
      Regarding the link part of a flyout: this again is a lot of work, unfortunately. You’ll need to use the DrawThemeBackground Win32 function for the background and GetThemeFont and GetThemeColor for the font (I have a post on the latter here). You’ll want to use the ‘Flyout’ class and get the ‘LinkArea’ (FLYOUT_LINKAREA) part. I guess in WPF you’d use DrawThemeBackground with a memory DC and display that with an Image. I recommend using Theme Explorer to browse the various classes, parts and states of the Windows theming system.
      If you decide to follow through with using those APIs, I’d love to see the resultant code. Good luck.

Leave a Reply

Your email address will not be published. Required fields are marked *