Skip to content

Latest commit

 

History

History
105 lines (69 loc) · 3.57 KB

deskband.md

File metadata and controls

105 lines (69 loc) · 3.57 KB

Desk Band Extensions

Desk Band Extensions are extensions which can run in the Windows Task Bar.

Screenshot: DeskBand

This document describes how to build a simple desk band extension.

Note: Officially, Desk Band extensions are no longer supported as of Windows 7 (see details here) and Taskbar Extensions).

Creating the Project

Create a new .NET Class Library project.

Add the following references:

  • System.Windows.Forms
  • System.Drawing

Now use the NuGet Package Manager console to add a reference to SharpShell:

Install-Package SharpShell

For the project to be able to be registered, it will need to have a strong name, which means it will need to be signed. Open the project properties, go to the 'Signing' section and choose 'Sign the Assembly'.

At this stage you have a new class library with the required references and signing setup to build a SharpShell DeskBand Server.

Create the DeskBand Interface

For this example we will create a simple desk band which offers the user the option to perform a Web Search.

Create a new User Control with the name DeskBandUI, add a text box for the search text and a button to run the search command:

Screenshot: Desk Band UI

The handler for the 'Go' button will browse to the Google Search results for the search text:

private void buttonGo_Click(object sender, EventArgs e)
{
    Process.Start("http://google.com#q=" + textBoxSearch.Text);
}

Create the DeskBand Server

You will now need to create a class which derives from SharpDeskBand:

[ComVisible(true)]
[DisplayName("Web Search")]
public class WebSearchDeskBand : SharpDeskBand
{
    protected override System.Windows.Forms.UserControl CreateDeskBand()
    {
        return new DeskBandUI();
    }

    protected override BandOptions GetBandOptions()
    {
        return new BandOptions
               {
                   HasVariableHeight = false,
                   IsSunken = false,
                   ShowTitle = true,
                   Title = "Web Search",
                   UseBackgroundColour = false,
                   AlwaysShowGripper = true
               };
    }
}

The CreateDeskBand function will return a new instance of your interface. The GetBandOptions function is called by the shell to determine layout and UI options for the server.

The server class itself needs to be visible as COM server, so we use the ComVisible attribute.

Install the DeskBand Server

Build the project and record the name of the generated dll file.

Now follow the Installing documentation to install the server.

Now restart the explorer.exe process. You should see the new desk band listed as a toolbar available to show in the Explorer Task Bar:

Screenshot: Web Search Option

The name used in this toolbar is specified by using the DisplayName attribute on the server class.

See Also