How do I create a toolbar that sits in the taskbar?


Commenter Nick asks, "How would you go about creating a special toolbar to sit on the taskbar like the Windows Media Player 10 minimised toolbar?"

You would look at the DeskBand API SDK Sample in the Windows Platform SDK.

The magic word is DeskBand. This MSDN page has an overview.

Bonus chatter: I've seen some online speculation as to whether a DeskBand counts as a shell extension, because of the guidance against writing shell extensions in managed code. As with all guidance, you need to understand the rationale behind the guidance so you can apply the guidance intelligently instead of merely following it blindly off a cliff. Summarizing the rationale: Since only one version of the CLR can exist in a process, any shell extension which runs inside the host process which uses the CLR may inject a version of the CLR that conflicts with the version of the CLR the host process (or some other component in the host process) wants to use. Now that you understand the reason, you also can answer the question, "Is a DeskBand a shell extension (for the purpose of this guidance)?" Yes, because DeskBands (like all other COM objects registered as in-process servers) run inside the host process.

As another example of how understanding the rationale behind guidance lets you know when the guidance no longer applies: In the time since the original guidance was developed, the CLR team came up with a way to run multiple versions of the CLR inside a single process (for specific values of "multiple"). Therefore, if you use one of those "I won't conflict with other versions of the CLR inside the same process" versions, then you can see that the rationale behind the guidance no longer applies.

Comments (12)
  1. Sunil Joshi says:

    Since only .NET 2.0 and .NET 4.0 CLRs can exist side-by-side in a process, would creating a .NET shell extension still cause a problem for anyone running .NET 1.0 or 1.1 applications?

    (i.e. problems with open / save dialog).

    I have no idea how widely used such applications are these days but I would have thought that was still a worry.

    [I don’t know either. I was just using it as an example of understanding the rationale behind guidance. You should ask the CLR folks. -Raymond]
  2. Ivo says:

    Windows Explorer (and Internet Explorer) can also host DeskBands. They are placed in a standard rebar control. However on Windows 7, Windows Explorer insists on adding the RBBS_BREAK style to every band, so every band appears on a new row. If the user rearranges the bars and restarts Explorer the bands will be back to one per row. Vista doesn’t have this problem. Internet Explorer on Wnidows 7 is also OK.

    Is there a way to prevent RBBS_BREAK from being added? IDeskBand::GetBandInfo doesn’t seem to provide such option. If not, is it a bug or there is a good reason for putting every band on a new line?

  3. someone else says:

    And now, with 7, this may be better solved with help of the SuperBar (like WMP11 does).

  4. Gabe says:

    That’s not the only rationale for the guidance to not make a CLR shell extension. For example, doing so could cause the CLR to load into every process that shows a system Open or Save dialog box. That will significantly increase the memory footprint of every app on the box, which is a very bad idea.

    On the other hand, if Explorer had been written to run DeskBands out-of-process, there would likely be no reason that you couldn’t write them with the CLR.

  5. someone says:

    After we create the DeskBand, the evil shell team will deprecate it in Windows 8 and suddenly pull the feature and force us to use Windows 7 taskbar functionality.

  6. Mark Jonson says:

    @someone else I hate that SuperBar. It’s much less functional than the old WMP DeskBar from Windows XP/Vista. It doesn’t show you the currently playing song, you have to hover over it and wait for it to appear vs the DeskBar that is always visible, and it doesn’t provide a progress bar (let alone a user-interactive one, as the DeskBar did). I can’t understand why Microsoft changed it. It’s probably the only regressive change in Windows 7 and I hope it gets changed back in the next version.

  7. Mark Sowul says:

    Agreed with Mark Jonson.  But sadly it is hardly the only regressive change.  Off the top of my head, other stuff I used to use that’s gone: "Find in Library," "Advanced Tag Editor," sidebar (you could already drag gadgets on the desktop, what’s the point of getting rid of the sidebar? Now I can’t keep them always-on-top), stocks gadget, column headers in explorer now appear only in details view, you can’t set group-by in explorer with column headers anymore, explorer advanced search options are gone, ultimate extras are gone…for what? Lower memory usage, Aero snaps, and jump lists?  Pass.

  8. hereafter says:

    Awesome tips

  9. Sunil Joshi says:

    @Mark Sowul

    Gadgets always on top in Windows 7

    Right click on a gadget and click always on top.

    Advanced Search Options in Explorer:

    Enter your search in the top right hand box – you can also add search filters through the same box.

  10. !wmp says:

    The only good thing about WMP is that EU banned it.

  11. Christian says:

    @!wmp

    No, that’s not a good thing. A good thing about it is that you decide whether to use it or not. Perhaps you didn’t know, now you do.

  12. someoneelse says:

    @someone

    No need to wait for Windows 8, deskbands are already deprecated in Windows 7.  See for example:

    http://msdn.microsoft.com/en-us/library/bb762067(VS.85).aspx

    IDeskBand Interface

    Deprecated. Used to obtain information about a band object.

    Note  We recommend that you use thumbnail toolbars in new development in place of desk bands.

Comments are closed.