All Your Base Are Belong To Us

Mostly .NET internals and other kinds of gory details

Windows 7 Taskbar: APIs

After all the introductions (see also the Windows 7 blog), there’s nothing left but to dive into the APIs you need to leverage the new Windows 7 Taskbar functionality.  The SDK contains reasonably good documentation for this stage of the product.  However, the documentation addresses the native code developer - Win 32 API and COM. What about all the managed code developers out there who want to opt into the Windows 7 Taskbar experience?  In the near future, the Windows Bridge (still a code name) project will include Windows 7 features like the Taskbar and Libraries.  However, until that time, we want to provide you with the following managed code wrapper for the Windows 7 Taskbar. This wrapper is based on the Vista Bridge Sample Library V1.3.

But first things first – where is the code?  How do you get the code?  By the time you read this, the code will have been uploaded to the MSDN Code Gallery, and can be downloaded from http://code.msdn.microsoft.com/Windows7Taskbar (direct download link).

By the way, if you want to understand the native side of things, then also take a look at Yochay’s partial overview of the native APIs (and there’s even more content on Channel9).

The general structure of the solution is:

Let’s take a sneak peek at the main classes that provide an entry point to the taskbar functionality (we will look at them in more detail in subsequent posts):

  • The Windows7Taskbar class provides low-level facilities for manipulating the process-wide and window-specific application ids, controlling custom window preview bitmaps, setting the taskbar overlay icon and progress bar and clipping the taskbar thumbnail.
  • The JumpListManager class provides an abstraction of the application jump list, including facilities to manipulate custom destinations, user tasks, recent/frequent lists and items removed by the user.
  • The ThumbButtonManager class provides an abstraction of the taskbar thumbnail toolbar, including the facilities to create thumbnail toolbar buttons and receive a notification when they are clicked.
  • The CustomWindowsManager class provides an abstraction of a customized window thumbnail preview and live preview (peek), including the facilities to receive a notification when a preview bitmap is requested by the Desktop Window Manager (DWM) and to automatically grab the preview bitmap of a window.

Let’s also see what the demo projects demonstrate:

  • The DocumentReader sample demonstrates how thumbnail clipping and thumbnail customization can provide a better user experience when the information displayed in the thumbnail is too small or unreadable by default.

image

  • The IMClient sample demonstrates how taskbar overlay icons and taskbar progress bars can light up an application’s taskbar button instead of relying on an additional dialog or on an icon in the system notification area (tray).

image image image

  • The WebBrowser sample demonstrates how custom window previews can be used to expose a list of child windows (browser tabs) as thumbnail- and peek-enabled windows in the taskbar. (Please note that due to the architecture of the underlying native feature, this managed implementation leaves much to be desired.)

image

  • The MainDemo sample demonstrates a glimpse into nearly each part of the new taskbar functionality, including registering a file type association, building a jump list with custom categories and custom tasks, setting an overlay icon and progress bar and many other features.

image

Curious what goes into the implementation of each feature?  How to use only a few lines of managed code to build a jump list, provide a taskbar progress bar or overlay icon, customize your thumbnail preview and more?  Stay tuned for subsequent posts.

Comments

Reflective Perspective - Chris Alcock » The Morning Brew #286 said:

Pingback from  Reflective Perspective - Chris Alcock  » The Morning Brew #286

# February 13, 2009 10:29 AM

All Your Base Are Belong To Us said:

Let’s get the easy stuff out of the way before we start building jump lists and customizing live previews

# February 16, 2009 1:36 PM

All Your Base Are Belong To Us said:

The Start Menu has long been with us; it provides a launch surface for applications and recent documents

# February 20, 2009 7:39 PM

All Your Base Are Belong To Us said:

In the previous installment in this series, we have seen how the default support for recent and frequent

# February 23, 2009 12:31 PM

All Your Base Are Belong To Us said:

Let’s recap what we’ve seen so far.  We’ve started with the fundamentals of the Windows 7 taskbar

# February 26, 2009 7:15 PM

All Your Base Are Belong To Us said:

Even without getting involved with the APIs, it’s clear that one of the most visually stunning features

# March 6, 2009 11:12 PM

All Your Base Are Belong To Us said:

In the previous post , we have only scratched the surface of how to provide a custom thumbnail and custom

# March 20, 2009 2:26 PM

Windows 7 for Developers said:

One of the first noticeable changes in Windows 7 Desktop is the new Taskbar. The Windows 7 Taskbar post

# April 3, 2009 10:40 AM

Windows 7 Taskbar .NET Sample Library ??? an Overview | Windows Seven 7 said:

Pingback from  Windows 7 Taskbar .NET Sample Library ??? an Overview | Windows Seven 7

# April 3, 2009 11:33 AM

You Get The . Info » Windows 7 Taskbar .NET Sample Library ??? an Overview - 11th Edition said:

Pingback from  You Get The . Info » Windows 7 Taskbar .NET Sample Library ??? an Overview - 11th Edition

# April 7, 2009 4:26 PM

Windows 7 Taskbar .NET Sample Library ??? an Overview | Blog said:

Pingback from  Windows 7 Taskbar .NET Sample Library ??? an Overview | Blog

# April 10, 2009 5:36 AM

Блог Windows 7 для разработчиков said:

Библиотека Windows 7 Taskbar .NET Sample Library ( ч .1) Одним из самых заметных изменений в Windows

# April 15, 2009 5:03 PM

Randy Magruder said:

The Build Jump List is now broken in Windows 7 RC.

Do we know when we'll get an updated bridge library?

Randy

# May 4, 2009 11:40 PM

Thomas Rosenstein said:

Alle die schon Windows 7 ausprobiert haben kennen natürlich die neuen Funktionalitäten der

# May 9, 2009 10:01 PM

Thomas Rosenstein said:

Alle die schon Windows 7 ausprobiert haben kennen natürlich die neuen Funktionalitäten der

# May 10, 2009 11:08 AM

bWindows 7 Taskbar/b: APIs - All Your Base Are Belong To Us « Windows 7 Live Info said:

Pingback from  bWindows 7 Taskbar/b: APIs - All Your Base Are Belong To Us «  Windows 7 Live Info

# May 18, 2009 9:11 PM

vivek said:

i love window 7

# May 19, 2009 2:16 PM

chang said:

Hi,

I downloaded the same sample application from: code.msdn.microsoft.com/.../ProjectReleases.aspx[^]

But whenever I run it & try to add a JumpList it throws me COM Exception. I am using WPF 3.5 SP1 in Windows 7.

What may be the problem & how can I resolve this? Any help regarding the same is soliciated. Thanks in advance...

The details of the exception is as below:

===========================================

System.Runtime.InteropServices.COMException was unhandled

Message="Exception from HRESULT: 0x80040F03"

Source="Windows7.DesktopIntegration"

ErrorCode=-2147217661

StackTrace:

at Windows7.DesktopIntegration.Interop.ICustomDestinationList.AppendCategory(String pszCategory, IObjectArray poa)

at Windows7.DesktopIntegration.JumpListDestinations.RefreshDestinations(ICustomDestinationList destinationList) in D:\installer\Windows7IntegrationLibrary_Taskbar_Libraries\Windows7IntegrationLibrary_Taskbar_Libraries\DesktopIntegration\Windows7.DesktopIntegration\JumpLists\JumpListImpl.cs:line 62

at Windows7.DesktopIntegration.JumpListManager.Refresh() in D:\installer\Windows7IntegrationLibrary_Taskbar_Libraries\Windows7IntegrationLibrary_Taskbar_Libraries\DesktopIntegration\Windows7.DesktopIntegration\JumpLists\JumpListManager.cs:line 418

at Windows7.DesktopIntegration.MainDemo.Windows7Form.btnBuildJumpList_Click(Object sender, EventArgs e) in D:\installer\Windows7IntegrationLibrary_Taskbar_Libraries\Windows7IntegrationLibrary_Taskbar_Libraries\Demo\Taskbar\Windows7.DesktopIntegration.MainDemo\Windows7Form.cs:line 256

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at Windows7.DesktopIntegration.MainDemo.Program.Main() in D:\installer\Windows7IntegrationLibrary_Taskbar_Libraries\Windows7IntegrationLibrary_Taskbar_Libraries\Demo\Taskbar\Windows7.DesktopIntegration.MainDemo\Program.cs:line 26

at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

InnerException:

# July 21, 2009 1:40 PM

Kent said:

I get the same exception chang described above. Could you help us solve this, please?

Thanks.

# July 28, 2009 11:39 AM

Арнольд said:

+1 к предыдущему комментарию :)

# August 19, 2009 3:00 AM

Twitter Trackbacks for Windows 7 Taskbar: APIs - All Your Base Are Belong To Us [microsoft.co.il] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Windows 7 Taskbar: APIs - All Your Base Are Belong To Us         [microsoft.co.il]        on Topsy.com

# September 1, 2009 11:18 AM

All Your Base Are Belong To Us said:

Yochay , a good friend and co-author of “Introducing Windows 7 for Developers” and of the “Windows 7

# November 19, 2009 3:11 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: