New work

This is the second Tuesday that I have given out info on some changes in the object
model for the next version. I think I am going to try and do a “New feature Tuesdays”
blog from now on.

This week’s topic: Passing bitmaps to VS.

In version 7.0/7.1, when we had an automation methods or properties where you could
pass a bitmap, and to pass that bitmap you would need to wrap it inside of a IPictureDisp
COM interface then call the method. This was a real pain for a couple of reasons.
First, you neded to deal with creating and setting the properties of an extra object,
an IPictureDisp interface. Second, you could not remote an IPictureDisp; this interface
does not cross process boundaries so you could not CoCreate an instance of VS and
set one of these images. Next, IPictureDisp is a COM concept, not an .NET one. If
you wanted to use an IPictureDisp, you would either need to call off to a VB specific
assembly to instantiate one of these interfaces, and it never worked right, VB would
munge the bitmap a bit, causing the image to not look right especially if it used
color 0x00fe00 (the transparency color); or you would need to create a P/Invoke call
(which is messy).

There are some changes for Whidbey that will change how bitmaps can be passed to methods
that accept images. The IPictureDisp method will still work, it needs to otherwise
we will be breaking existing code. But we were lucky, when we created the methods
that take images we set them up to take Variants (this was not exactly by design,
but it worked out in our favor), and because they take Variants, we can accept other
data types. These other data types include strings and integers (VT_INT). When you
call on of the image APIs, you can now pass either a string, which is the path to
a bitmap, or a HBITMAP to a bitmap (found in .NET using the System.Drawing.Bitmap.GetHbitmap()
method). These changes will be made to the APIs for setting a picture on a Add-in
created tab-linked tool window (SetTabPicture), setting a custom animation in the
status bar (Animate), and the bitmap shown next to a task list item (Add). We will
not be fundamentally changing the API of how you set a bitmap for a tool bar button
(AddNamedCommand), but we will be making it a bit easier (description of that will
be available in a future blog).

Comments (0)

Skip to main content