N
Nathan Hapke
Hi all,
I'm working on an Outlook (target versions are 2003 and 2007) addin to
add a CommandBarButton to the Standard toolbar of the main Explorer
window, and Mail Inspector windows. I'm writing this in C#.
I want a custom icon on the button, I initially used the
Clipboard.SetDataObject(...) and button.PasteFace(), which does seem to
work, however, the fact that it overwrites the clipboard is a bit of a
show stopper.
I'm trying to rewrite my code to use the AxHost, and hopefully be able
to set a Mask as well to get transparency:
ResourceManager rm = MyProject.Properties.Resources.ResourceManager;
stdole.IPictureDisp tempImage = null;
ImageList newImageList = new ImageList();
newImageList.Images.Add((Icon)rm.GetObject("buttonIcon"));
tempImage = ConvertImage.Convert(newImageList.Images[0]);
button.Picture = tempImage;
//repeat to set the .Mask
sealed public class ConvertImage : System.Windows.Forms.AxHost {
public ConvertImage() : base(Guid.Empty.ToString()) {
}
public static stdole.IPictureDisp Convert
(System.Drawing.Image image) {
return (stdole.IPictureDisp)System.
Windows.Forms.AxHost.GetIPictureDispFromPicture(image);
}
}
but doing so crashes Outlook with a 0x8000FFFF, which is what I see from
http://support.microsoft.com/kb/286460/en-us.
Can anyone see anything wrong with what I've done?
Thanks in advance,
Nathan
I'm working on an Outlook (target versions are 2003 and 2007) addin to
add a CommandBarButton to the Standard toolbar of the main Explorer
window, and Mail Inspector windows. I'm writing this in C#.
I want a custom icon on the button, I initially used the
Clipboard.SetDataObject(...) and button.PasteFace(), which does seem to
work, however, the fact that it overwrites the clipboard is a bit of a
show stopper.
I'm trying to rewrite my code to use the AxHost, and hopefully be able
to set a Mask as well to get transparency:
ResourceManager rm = MyProject.Properties.Resources.ResourceManager;
stdole.IPictureDisp tempImage = null;
ImageList newImageList = new ImageList();
newImageList.Images.Add((Icon)rm.GetObject("buttonIcon"));
tempImage = ConvertImage.Convert(newImageList.Images[0]);
button.Picture = tempImage;
//repeat to set the .Mask
sealed public class ConvertImage : System.Windows.Forms.AxHost {
public ConvertImage() : base(Guid.Empty.ToString()) {
}
public static stdole.IPictureDisp Convert
(System.Drawing.Image image) {
return (stdole.IPictureDisp)System.
Windows.Forms.AxHost.GetIPictureDispFromPicture(image);
}
}
but doing so crashes Outlook with a 0x8000FFFF, which is what I see from
http://support.microsoft.com/kb/286460/en-us.
Can anyone see anything wrong with what I've done?
Thanks in advance,
Nathan