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
:
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
?
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!!!
if (TaskbarManager.IsPlatformSupported)
{
}
CodeProject