Click here to Skip to main content
15,879,535 members
Articles / Programming Languages / C#

Anatomy of the Windows 7 Taskbar - ThumbnailToolbarButton

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
1 Apr 2010CPOL1 min read 13.2K   8  
With Windows 7’s public release less than 2 weeks away (22 October 2009), I decided to dig into how the taskbar works!

With Windows 7’s public release less than 2 weeks away (22 October 2009), I decided to dig into how the taskbar works! I will specifically be looking at it from a developers' point of view! Before we start, download the Windows® API Code Pack for Microsoft® .NET Framework.

The Windows® API Code Pack for Microsoft® .NET Framework provides a source code library that can be used to access some new Windows 7 features (and some existing features of older versions of Windows operating system) from managed code. These Windows features are not available to developers today in the .NET Framework.

The first part we will be dissecting is the ThumbnailToolbarButton:

C#
buttonPrevious = new ThumbnailToolbarButton(Properties.Resources.prevArrow, "Previous");
buttonPrevious.Enabled = false;
buttonPrevious.Click += 
	new EventHandler<thumbnailbuttonclickedeventargs>(buttonPrevious_Click);

buttonNext = new ThumbnailToolbarButton(Properties.Resources.nextArrow, "Next");
buttonNext.Enabled = false;
buttonNext.Click += new EventHandler<thumbnailbuttonclickedeventargs>(buttonNext_Click);

buttonPlay = new ThumbnailToolbarButton(Properties.Resources.play, "Play");
buttonPlay.Click += new EventHandler<thumbnailbuttonclickedeventargs>(buttonPlay_Click);

And to actually add it to the TabbedThumbnail?

C#
TaskbarManager.Instance.ThumbnailToolbars.AddButtons
(new WindowInteropHelper(this).Handle, buttonPrevious, buttonPlay, buttonNext);

Other properties of note:

  • IsInteractive - Non-interactive buttons don't display any hover behavior nor do they raise click events. They are intended to be used as status icons. This is mostly similar to being not Enabled, but the image is not desaturated.
  • DismissOnClick - If set to true, the taskbar button's flyout will close immediately. Default is true.
  • Enabled - If the button is disabled, it is present, but has a visual state that indicates that it will not respond to user action. Default is true.

We will be seeing more and more of this kind of integration in the future! Web browsers forward/back navigation integration, Media player play/next/previous, etc.!

P.S. Don’t forget to check if your OS supports this before just using it!!!

C#
if (TaskbarManager.IsPlatformSupported)
{
    // ...
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --