Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Custom Image added to CommandBar Buttons

Geek News

Custom Image added to CommandBar Buttons
Andrew 11/25/2008 10:29:01 PM
Hello All,

I have an add-in developed in Visual Studio 2008, written in VB.Net for
Outlook 2003 that I'm trying to add a custom image to commandbar buttons that
I created. The image displays correctly in every inspector window except when
I select Microsoft Word as the email editor. When that is selected and I open
a New mail, it throws the following error: "Catastrophic failure (Exception
from HRESULT: 0x8000FFFF (E_UNEXPECTED))"

This is happening on my development machine!

The code to add the custom image was also ported to another project for
Outlook 2007 which works flawlessly.

Here is the class where I get the image and store it in a global variable
which I'm adding to the ".Picture" property of button when its created.

Public Class clsScaryFace
Inherits System.Windows.Forms.AxHost

Public Sub New()
MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
End Sub

Public Sub GetScaryFace()
Dim scaryFaceImage As Bitmap = Nothing
'Dim scaryFaceMask As Bitmap = Nothing
Try
scaryFaceImage = My.Resources.Scaryface.scaryface
If (Exists(scaryFaceImage)) Then
g_imgScaryFace = Convert(scaryFaceImage)
End If

Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
scaryFaceImage = Nothing
End Try
End Sub

Private Function Convert(ByVal Image As System.Drawing.Image) As
stdole.IPictureDisp
Convert = CType(GetIPictureDispFromPicture(Image),
stdole.IPictureDisp)
End Function
End Class

I have no idea why this breaks when WordMail is selected as the editor; any
assistance would be greatly appreciated.

Regards
Re: Custom Image added to CommandBar Buttons
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/25/2008 11:54:42 PM
..Picture and .Mask take IPictureDisp objects, which cannot be passed across
process boundaries. WordMail 2003 is a subclassed word.exe and so is running
in another process space. You must use .PasteFace for WordMail 2003 button
images. Put the image on the clipboard and .PasteFace will take it from
there.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Andrew" <Andrew[ at ]discussions.microsoft.com> wrote in message
news:D6691230-AAF6-4CB1-A57B-6D9D07BFA92A[ at ]microsoft.com...
[Quoted Text]
> Hello All,
>
> I have an add-in developed in Visual Studio 2008, written in VB.Net for
> Outlook 2003 that I'm trying to add a custom image to commandbar buttons
> that
> I created. The image displays correctly in every inspector window except
> when
> I select Microsoft Word as the email editor. When that is selected and I
> open
> a New mail, it throws the following error: "Catastrophic failure
> (Exception
> from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
>
> This is happening on my development machine!
>
> The code to add the custom image was also ported to another project for
> Outlook 2007 which works flawlessly.
>
> Here is the class where I get the image and store it in a global variable
> which I'm adding to the ".Picture" property of button when its created.
>
> Public Class clsScaryFace
> Inherits System.Windows.Forms.AxHost
>
> Public Sub New()
> MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
> End Sub
>
> Public Sub GetScaryFace()
> Dim scaryFaceImage As Bitmap = Nothing
> 'Dim scaryFaceMask As Bitmap = Nothing
> Try
> scaryFaceImage = My.Resources.Scaryface.scaryface
> If (Exists(scaryFaceImage)) Then
> g_imgScaryFace = Convert(scaryFaceImage)
> End If
>
> Catch ex As Exception
> MessageBox.Show(ex.Message)
> Finally
> scaryFaceImage = Nothing
> End Try
> End Sub
>
> Private Function Convert(ByVal Image As System.Drawing.Image) As
> stdole.IPictureDisp
> Convert = CType(GetIPictureDispFromPicture(Image),
> stdole.IPictureDisp)
> End Function
> End Class
>
> I have no idea why this breaks when WordMail is selected as the editor;
> any
> assistance would be greatly appreciated.
>
> Regards

RE: Custom Image added to CommandBar Buttons
Andrew 11/26/2008 2:26:01 PM
Thanks a lot Ken!

Regards,
Andrew

"Andrew" wrote:

[Quoted Text]
> Hello All,
>
> I have an add-in developed in Visual Studio 2008, written in VB.Net for
> Outlook 2003 that I'm trying to add a custom image to commandbar buttons that
> I created. The image displays correctly in every inspector window except when
> I select Microsoft Word as the email editor. When that is selected and I open
> a New mail, it throws the following error: "Catastrophic failure (Exception
> from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
>
> This is happening on my development machine!
>
> The code to add the custom image was also ported to another project for
> Outlook 2007 which works flawlessly.
>
> Here is the class where I get the image and store it in a global variable
> which I'm adding to the ".Picture" property of button when its created.
>
> Public Class clsScaryFace
> Inherits System.Windows.Forms.AxHost
>
> Public Sub New()
> MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
> End Sub
>
> Public Sub GetScaryFace()
> Dim scaryFaceImage As Bitmap = Nothing
> 'Dim scaryFaceMask As Bitmap = Nothing
> Try
> scaryFaceImage = My.Resources.Scaryface.scaryface
> If (Exists(scaryFaceImage)) Then
> g_imgScaryFace = Convert(scaryFaceImage)
> End If
>
> Catch ex As Exception
> MessageBox.Show(ex.Message)
> Finally
> scaryFaceImage = Nothing
> End Try
> End Sub
>
> Private Function Convert(ByVal Image As System.Drawing.Image) As
> stdole.IPictureDisp
> Convert = CType(GetIPictureDispFromPicture(Image),
> stdole.IPictureDisp)
> End Function
> End Class
>
> I have no idea why this breaks when WordMail is selected as the editor; any
> assistance would be greatly appreciated.
>
> Regards

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net