What it looks like you are trying to do is load the picture from the
clipboard. If the picture and mask are not in the clipboard you cannot get
them out of the clipboard.
Here is my code that does what you are trying to do.
using stdole
/// <summary>
/// AxHost2 is a derivative of AxHost for getting IPictureDisp from a .NET
image type
/// </summary>
internal class AxHost2 : AxHost
{
public AxHost2() : base(null)
{}
new public static IPictureDisp GetIPictureDispFromPicture(Image image)
{
return (IPictureDisp) AxHost.GetIPictureDispFromPicture(image);
}
}
public static void AssignButtonImageAndMask(ref CommandBarButton button,
string imageName, string imageMask)
{
//adds a custom icon to the face
ResourceManager rm = new ResourceManager(typeof(OutlookUtilities).Namespace
+ <ResourceImageFileName> typeof(OutlookUtilities).Assembly);
using (Bitmap bmp = (Bitmap) rm.GetObject(imageName))
{
if (bmp != null)
{
button.Picture = AxHost2.GetIPictureDispFromPicture(bmp);
}
}
using (Bitmap bmp = (Bitmap) rm.GetObject(imageMask))
{
if (bmp != null)
{
button.Mask = AxHost2.GetIPictureDispFromPicture(bmp);
}
}
}
That bit of code should help you along.
Regards,
Thaddaeus.