Carlos Quintero (Microsoft MVP) blog

Visual Studio Extensibility with Add-ins

Solved: transparent bitmaps in add-in toolwindows of VS 2010 (Beta 1)

In the previous post I explained how to get transparent bitmaps for add-in commands in VS 2010 Beta 1 and previous versions. Now it is the turn of toolwindow bitmaps. Again, if you have a .NET 2.0 add-in that uses XML registration and a managed satellite DLL and targets VS 2005, 2008 and 2010 Beta 1, the situation is as follows:

1) Toolwindow bitmaps for VS 2005:

- Use either:

   * A 32-bit bitmap with transparency in the alpha channel.
   * A 24-bit bitmap with RGB=255,0,255 (magenta) as transparent color

- Call EnvDTE.Window.SetTabPicture(bitmap.GetHbitmap) (for some reason passing bitmap.GetHbitmap().ToInt32 causes System.ArgumentException: Value does not fall within the expected range)
- Call EnvDTE.Window.Visible = True (this must be done after setting the toolwindow picture)

2) Toolwindow bitmaps for VS 2008:

- Use either:

   * A 32-bit bitmap with transparency in the alpha channel.
   * If the color depth of the screen is:
        - 16-bit, you can use a 24-bit bitmap with RGB=0,254,0 (almost pure green) or a 24-bit bitmap with RGB=255,0,255 (magenta) as transparent color
        - 24-bit: I couldn't test this case on my computers.
        - 32-bit: you need to make the bitmap transparent calling bitmap.MakeTransparent(<background color>).

- Call EnvDTE.Window.SetTabPicture(bitmap.GetHbitmap().ToInt32()) (for some reason passing just bitmap.GetHbitmap causes System.ArgumentException. You need to convert the IntPtr to integer)
- Call EnvDTE.Window.Visible = True (this must be done after setting the toolwindow picture)

3) Toolwindow bitmaps for VS 2010 Beta 1:

- Use either.
   * A 32-bit bitmap with transparency in the alpha channel. Due to a bug that I have already reported, in this case the toolwindow picture shows transparency when focused, but doesn't when not focused.
   * A 24-bit bitmap with RGB=0,254,0 (almost pure green) as transparent color
   * A 24-bit bitmap with RGB=255,0,255 (magenta) as transparent color

- Call either EnvDTE.Window.SetTabPicture(bitmap.GetHbitmap()) or EnvDTE.Window.SetTabPicture(bitmap.GetHbitmap().ToInt32())
- Call EnvDTE.Window.Visible = True (this must be done after setting the toolwindow picture)

Bottom line: if the bug mentioned above with VS 2010 and 32-bit bitmap with transparency in the alpha channel is fixed for VS 2010 final release (Update, August 6: VS 2010 Beta 2 will fix it), you will be able to use 32-bit bitmap with transparency in the alpha channel in the three VS versions, but taking into account that sometimes you need to use the IntPtr value returned by GetHBitmap, and others its Int32 value.

I hope the information above is accurate because it is really messing to test all cases. Let me know if you can corroborate or not.

Published Thu, Jun 25 2009 6:27 by carlosq
Filed under:

Comments

# MS fixing problem with 32-bit bitmaps with alpha channel for transparency in SetTabPicture method of toolwindows@ Thursday, August 06, 2009 4:56 AM

The little problem that I reported when using the SetTabPicture method with a 32-bit bitmap with alpha

# CommandBarButton.Mask property deprecated in VS 2010@ Saturday, October 24, 2009 2:48 AM

As you already know from my posts in the last months, VS 2010 will use WPF-based commandbars and will

# More (good news) on Visual Studio 2010 getting rid of satellite DLLs for add-ins@ Saturday, October 24, 2009 2:49 AM

In my last post Visual Studio 2010 getting rid of satellite DLLs for add-ins I mentioned that VS 2010

Leave a Comment

(required) 
(required) 
(optional)
(required)