Windows 7 Taskbar: APIs

February 12, 2009

tags:
7 comments

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.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

7 comments

  1. Randy MagruderMay 4, 2009 ב 11:40 PM

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

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

    Randy

    Reply
  2. vivekMay 19, 2009 ב 2:16 PM

    i love window 7

    Reply
  3. changJuly 21, 2009 ב 1:40 PM

    Hi,

    I downloaded the same sample application from: http://code.msdn.microsoft.com/Windows7Taskbar/Release/ProjectReleases.aspx?ReleaseId=2246^]

    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:

    Reply
  4. KentJuly 28, 2009 ב 11:39 AM

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

    Thanks.

    Reply
  5. АрнольдAugust 19, 2009 ב 3:00 AM

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

    Reply
  6. bandsxbandsFebruary 7, 2010 ב 7:56 PM

    Virtual Memory sure is becoming cheaper and cheaper and cheaper. I’m curious as to when we will eventually hit the rate of 1c to 1 GB.

    I’m still waiting for the day when I will finally be able to afford a 20 TB harddisk, lol. But for now I will be satisfied with having a 16 GB Micro SD in my R4i.

    (Submitted on BB for R4i Nintendo DS.)

    Reply
  7. MassimilianoAugust 24, 2011 ב 11:32 AM

    Do you know how I can disable close button in win 7 taskbar preview?

    Reply