Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Clipz - A Friendly Introduction to the Windows 7 Taskbar Features

, 17 Dec 2009
An overview of the Windows 7 taskbar features, and how to use then in your own applications.
Clipz.zip
Clipz
bin
Debug
Clipz.csproj.user
CopyIcon.ico
DeleteIcon.ico
Model
Native Methods
Properties
Settings.settings
Resources
Audio.png
Clipboard.png
NextIcon.ico
PreviousIcon.ico
Utility
Core
AppRestartRecovery
Dialogs
Common
TaskDialogs
Interop
AppRestartRecovery
Dialogs
NetworkList
PowerManagement
TaskDialogs
NetworkList
PowerManagement
Properties
PropertySystem
SafeHandles
Libraries
StructureMap.dll
Shell
Common
CommonFileDialogs
Controls
Design
ShellObjects.cd
ShellThumbnailClassDiagram.cd
DesktopWindowManager
ExplorerBrowser
ExplorerBrowserDiagram.cd
Interop
Common
Dialogs
ExplorerBrowser
KnownFolders
PropertySystem
StockIcons
Taskbar
KnownFolders
Properties
PropertySystem
StockIcons
Taskbar
//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Windows;

namespace Microsoft.WindowsAPICodePack.Taskbar
{
    /// <summary>
    /// Thumbnail toolbar manager class for adding a thumbnail toolbar with a specified set of buttons 
    /// to the thumbnail image of a window in a taskbar button flyout.
    /// </summary>
    public class ThumbnailToolbarManager
    {

        internal ThumbnailToolbarManager()
        {
            // Hide the public constructor so users can't create an instance of this class.
        }

        /// <summary>
        /// Adds thumbnail toolbar for the specified window.
        /// </summary>
        /// <param name="windowHandle">Window handle for which the thumbnail toolbar buttons need to be added</param>
        /// <param name="buttons">Thumbnail buttons for the window's thumbnail toolbar</param>
        /// <exception cref="System.ArgumentException">If the number of buttons exceed the maximum allowed capacity (7).</exception>
        /// <exception cref="System.ArgumentException">If the Window Handle passed in invalid</exception>
        /// <remarks>After a toolbar has been added to a thumbnail, buttons can be altered only through various 
        /// properties on the <see cref="T:Microsoft.WindowsAPICodePack.Taskbar.ThumbnailToolbarButton"/>. While individual buttons cannot be added or removed, 
        /// they can be shown and hidden through <see cref="P:Microsoft.WindowsAPICodePack.Taskbar.ThumbnailToolbarButton.Visible"/> as needed. 
        /// The toolbar itself cannot be removed without re-creating the window itself.
        /// </remarks>
        public void AddButtons(IntPtr windowHandle, params ThumbnailToolbarButton[] buttons)
        {
            if (windowHandle == IntPtr.Zero)
                throw new ArgumentException("Window handle cannot be empty", "windowHandle");
            if (buttons != null && buttons.Length == 0)
                throw new ArgumentException("Null or empty arrays are not allowed.", "buttons");
            if (buttons.Length > 7)
                throw new ArgumentException("Maximum number of buttons allowed is 7.", "buttons");

            // Add the buttons to our window manager, which will also create a proxy window
            TaskbarWindowManager.Instance.AddThumbnailButtons(windowHandle, buttons);
        }

        /// <summary>
        /// Adds thumbnail toolbar for the specified WPF Control.
        /// </summary>
        /// <param name="control">WPF Control for which the thumbnail toolbar buttons need to be added</param>
        /// <param name="buttons">Thumbnail buttons for the window's thumbnail toolbar</param>
        /// <exception cref="System.ArgumentException">If the number of buttons exceed the maximum allowed capacity (7).</exception>
        /// <exception cref="System.ArgumentNullException">If the control passed in null</exception>
        /// <remarks>After a toolbar has been added to a thumbnail, buttons can be altered only through various 
        /// properties on the ThumbnailToolbarButton. While individual buttons cannot be added or removed, 
        /// they can be shown and hidden through ThumbnailToolbarButton.Visible as needed. 
        /// The toolbar itself cannot be removed without re-creating the window itself.
        /// </remarks>
        public void AddButtons(UIElement control, params ThumbnailToolbarButton[] buttons)
        {
            if (control == null)
                throw new ArgumentNullException("Control cannot be null", "control");
            if (buttons != null && buttons.Length == 0)
                throw new ArgumentException("Null or empty arrays are not allowed.", "buttons");
            if (buttons.Length > 7)
                throw new ArgumentException("Maximum number of buttons allowed is 7.", "buttons");

            // Add the buttons to our window manager, which will also create a proxy window
            TaskbarWindowManager.Instance.AddThumbnailButtons(control, buttons);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

TylerBrinks
Web Developer PageLabs
United States United States
I'm the founder of PageLabs, a web-based performance and SEO optimization site.

Give your site a boost in performance, even take a free speed test!
 
http://www.pagelabs.com
Follow on   Twitter

| Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 17 Dec 2009
Article Copyright 2009 by TylerBrinks
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid