Question

I am trying to implement a DeskBand in the Taskbar for my app and I have checked the documentation but it's very sparse. It does not explain how implement the IDeskBand2 interface.

I've found very little information online about this and the stuff I have found does not work. I found what looked to be a promising piece of code on CodeProject to be no more than a fountain of compiletime errors, until today, when I stumbled upon this website.

So far, what I've got is this:

class COMInterop
{
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [Guid("79D16DE4-ABEE-4021-8D9D-9169B261D657")]

    public interface IDeskBand2
    {
        void GetWindow(out System.IntPtr phwnd);
        void ContextSensitiveHelp([In] bool fEnterMode);
        void ShowDW([In] bool fShow);
        void CloseDW([In] UInt32 dwReserved);
        void ResizeBorderDW(IntPtr prcBorder, [In, MarshalAs(UnmanagedType.IUnknown)] Object punkToolbarSite, bool fReserved);

        void GetBandInfo(UInt32 dwBandID, UInt32 dwViewMode, ref DESKBANDINFO pdbi);
        bool CanRenderComposited();
        bool GetCompositionState();
        void SetCompositionState(bool fCompositionEnabled);
    }
}

which is inside a Class file called COMInterop.cs.

The problem I have now is on line 24. It says The type or namespace 'DESKBANDINFO could not be found. (are you missing a using directive or an assembly reference?)

How do I implement this - and do you have any good documentation for a DeskBand (see pic below) for Windows 7+?

enter image description here

Was it helpful?

Solution

DESKBAND info is a struct documented here. You can find a C# translation on pinvoke.net.

[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
    public int X;
    public int Y;

    public POINT(int x, int y)
    {
        this.X = x;
        this.Y = y;
    }

    public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y) { }

    public static implicit operator System.Drawing.Point(POINT p)
    {
        return new System.Drawing.Point(p.X, p.Y);
    }

    public static implicit operator POINT(System.Drawing.Point p)
    {
        return new POINT(p.X, p.Y);
    }
}

[StructLayout (LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct DESKBANDINFO {
    public uint dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)]
    public String wszTitle;
    public uint dwModeFlags;
    public Int32 crBkgnd; 
}

The deskband API documentation clearly states that it is a deprecated API. It says:

Important You should use thumbnail toolbars in new development in place of desk bands, which are not supported as of Windows 7.

In other words, you should almost certainly not be solving your problem with the deskband API.

That said, if you want to learn how to use deskband API look for example code in C++. Don't restrict the search to C#. Expect to find good examples in C++ but not in C#.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top