A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Icons does not appear in a CommandBar : Catastrophic failure throw



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 15th 08, 07:21 PM posted to microsoft.public.outlook.program_addins
Hichem S
external usenet poster
 
Posts: 13
Default Icons does not appear in a CommandBar : Catastrophic failure throw

I am using outlook 2003. When creating a new mail with WordEditor enabled, an
exception is thrown. I tried to debug and the exception gets thrown (see
code below) when I try to set the picture/mask property of a button.
My buttons are created by my outlook add-in with my word add-in disabled.
If I disable the outlook add-in and enable the word one, the buttons
creation is successful.
Thank you for your help...

Here is how I create my menubar and button :

CommandBar menuBar = context.GetCommandBars().ActiveMenuBar;

int controlCount = menuBar.Controls.Count;
// Add the menu two positions before the last one which is
"Help" (before Help and Windows menus).
CommandBarPopup rootMenu = (CommandBarPopup) menuBar.Controls.Add(
MsoControlType.msoControlPopup, Missing.Value,
Missing.Value, controlCount - 1, true);
if (rootMenu == null)
{
return null;
}
rootMenu.Caption = "ProductNameMenu";
rootMenu.Tag = NAME_MENU_BAR;
rootMenu.DescriptionText = "ProductName";
rootMenu.OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
rootMenu.TooltipText = "ProductName";
rootMenu.Visible = true;
rootMenu.Enabled = true;
return AddMenuButtons(context, rootMenu);



CommandBarButton myButton = (CommandBarButton)
rootMenu.Controls.Add(MsoControlType.msoControlBut ton, Missing.Value,
Missing.Value, Missing.Value, true);
myButton .Caption = "Caption";
myButton .Style = MsoButtonStyle.msoButtonAutomatic;
myButton .TooltipText = context.GetButtonSuperTip();
myButton .DescriptionText = context.GetButtonSuperTip();
myButton .OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
myButton .Mask = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen tMask);
myButton .Visible = true;
myButton .Enabled = true;


// This the class that helps to implement GetIPictureDispFromImage

public class AxHelper : AxHost
{
private AxHelper()
: base(null){}

public static IPictureDisp GetIPictureDispFromImage(Image image)
{
return (IPictureDisp)GetIPictureDispFromPicture(image);
}


public new static IPicture GetIPictureFromPicture(Image image)
{
return GetIPictureFromPicture(image);
}
}
Ads
  #2  
Old September 15th 08, 08:32 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Icons does not appear in a CommandBar : Catastrophic failure throw

When using WordMail you cannot use the Picture/Mask properties.

WordMail is a subclassed version of msword.exe used by Outlook as the email
editor. As such it runs in the Word process space and not in the Outlook
process space. Picture and Mask take IPictureDisp objects, which cannot be
passed across process boundaries, therefore the exceptions.

For WordMail 2003 you must use the clipboard and the PasteFace() method of
the button to add an image. Therefore any masking you do must be done on the
clipboard image.

See if that solves your problem.

--
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


"Hichem S" wrote in message
...
I am using outlook 2003. When creating a new mail with WordEditor enabled,
an
exception is thrown. I tried to debug and the exception gets thrown (see
code below) when I try to set the picture/mask property of a button.
My buttons are created by my outlook add-in with my word add-in disabled.
If I disable the outlook add-in and enable the word one, the buttons
creation is successful.
Thank you for your help...

Here is how I create my menubar and button :

CommandBar menuBar = context.GetCommandBars().ActiveMenuBar;

int controlCount = menuBar.Controls.Count;
// Add the menu two positions before the last one which is
"Help" (before Help and Windows menus).
CommandBarPopup rootMenu = (CommandBarPopup)
menuBar.Controls.Add(
MsoControlType.msoControlPopup, Missing.Value,
Missing.Value, controlCount - 1, true);
if (rootMenu == null)
{
return null;
}
rootMenu.Caption = "ProductNameMenu";
rootMenu.Tag = NAME_MENU_BAR;
rootMenu.DescriptionText = "ProductName";
rootMenu.OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
rootMenu.TooltipText = "ProductName";
rootMenu.Visible = true;
rootMenu.Enabled = true;
return AddMenuButtons(context, rootMenu);



CommandBarButton myButton = (CommandBarButton)
rootMenu.Controls.Add(MsoControlType.msoControlBut ton, Missing.Value,
Missing.Value, Missing.Value, true);
myButton .Caption = "Caption";
myButton .Style = MsoButtonStyle.msoButtonAutomatic;
myButton .TooltipText = context.GetButtonSuperTip();
myButton .DescriptionText = context.GetButtonSuperTip();
myButton .OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
myButton .Mask = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen tMask);
myButton .Visible = true;
myButton .Enabled = true;


// This the class that helps to implement GetIPictureDispFromImage

public class AxHelper : AxHost
{
private AxHelper()
: base(null){}

public static IPictureDisp GetIPictureDispFromImage(Image image)
{
return (IPictureDisp)GetIPictureDispFromPicture(image);
}


public new static IPicture GetIPictureFromPicture(Image image)
{
return GetIPictureFromPicture(image);
}
}


  #3  
Old September 15th 08, 10:11 PM posted to microsoft.public.outlook.program_addins
Hichem S
external usenet poster
 
Posts: 13
Default Icons does not appear in a CommandBar : Catastrophic failure t

Do you have a C# code regarding this precific issue?



"Ken Slovak - [MVP - Outlook]" wrote:

When using WordMail you cannot use the Picture/Mask properties.

WordMail is a subclassed version of msword.exe used by Outlook as the email
editor. As such it runs in the Word process space and not in the Outlook
process space. Picture and Mask take IPictureDisp objects, which cannot be
passed across process boundaries, therefore the exceptions.

For WordMail 2003 you must use the clipboard and the PasteFace() method of
the button to add an image. Therefore any masking you do must be done on the
clipboard image.

See if that solves your problem.

--
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


"Hichem S" wrote in message
...
I am using outlook 2003. When creating a new mail with WordEditor enabled,
an
exception is thrown. I tried to debug and the exception gets thrown (see
code below) when I try to set the picture/mask property of a button.
My buttons are created by my outlook add-in with my word add-in disabled.
If I disable the outlook add-in and enable the word one, the buttons
creation is successful.
Thank you for your help...

Here is how I create my menubar and button :

CommandBar menuBar = context.GetCommandBars().ActiveMenuBar;

int controlCount = menuBar.Controls.Count;
// Add the menu two positions before the last one which is
"Help" (before Help and Windows menus).
CommandBarPopup rootMenu = (CommandBarPopup)
menuBar.Controls.Add(
MsoControlType.msoControlPopup, Missing.Value,
Missing.Value, controlCount - 1, true);
if (rootMenu == null)
{
return null;
}
rootMenu.Caption = "ProductNameMenu";
rootMenu.Tag = NAME_MENU_BAR;
rootMenu.DescriptionText = "ProductName";
rootMenu.OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
rootMenu.TooltipText = "ProductName";
rootMenu.Visible = true;
rootMenu.Enabled = true;
return AddMenuButtons(context, rootMenu);



CommandBarButton myButton = (CommandBarButton)
rootMenu.Controls.Add(MsoControlType.msoControlBut ton, Missing.Value,
Missing.Value, Missing.Value, true);
myButton .Caption = "Caption";
myButton .Style = MsoButtonStyle.msoButtonAutomatic;
myButton .TooltipText = context.GetButtonSuperTip();
myButton .DescriptionText = context.GetButtonSuperTip();
myButton .OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
myButton .Mask = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen tMask);
myButton .Visible = true;
myButton .Enabled = true;


// This the class that helps to implement GetIPictureDispFromImage

public class AxHelper : AxHost
{
private AxHelper()
: base(null){}

public static IPictureDisp GetIPictureDispFromImage(Image image)
{
return (IPictureDisp)GetIPictureDispFromPicture(image);
}


public new static IPicture GetIPictureFromPicture(Image image)
{
return GetIPictureFromPicture(image);
}
}



  #4  
Old September 15th 08, 10:37 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Icons does not appear in a CommandBar : Catastrophic failure t

What specific issue, masking an image? No, I don't have sample code for
that. I don't know if there are any samples in C# for that at
www.outlookcode.com, but you can take a look 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


"Hichem S" wrote in message
...
Do you have a C# code regarding this precific issue?


  #5  
Old September 15th 08, 10:54 PM posted to microsoft.public.outlook.program_addins
Hichem S
external usenet poster
 
Posts: 13
Default Icons does not appear in a CommandBar : Catastrophic failure t

Look at this C++ example :
http://support.microsoft.com/kb/288771
You see that it's a bit specific!
it's not only : button.mask = image!!
Thanks


"Ken Slovak - [MVP - Outlook]" wrote:

What specific issue, masking an image? No, I don't have sample code for
that. I don't know if there are any samples in C# for that at
www.outlookcode.com, but you can take a look 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


"Hichem S" wrote in message
...
Do you have a C# code regarding this precific issue?



  #6  
Old September 16th 08, 02:20 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Icons does not appear in a CommandBar : Catastrophic failure t

That sort of thing is what you need to mask the image. As I said before you
cannot use the Mask or Picture properties from an out-of-process call.

The example you cite isn't C++, it's VB 6 code. It just uses a lot of Win32
API calls.

To use that code you'd need to translate it into C# or VB.NET and take
especial care with the memory management and release calls so you don't leak
handles.

--
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


"Hichem S" wrote in message
...
Look at this C++ example :
http://support.microsoft.com/kb/288771
You see that it's a bit specific!
it's not only : button.mask = image!!
Thanks


  #7  
Old September 16th 08, 04:17 PM posted to microsoft.public.outlook.program_addins
Hichem S
external usenet poster
 
Posts: 13
Default Icons does not appear in a CommandBar : Catastrophic failure t

Anyway...
You said : "WordMail is a subclassed version of msword.exe used by Outlook
as the email editor. As such it runs in the Word process space and not in the
Outlook
process space. Picture and Mask take IPictureDisp objects, which cannot be
passed across process boundaries, therefore the exceptions."


In this example
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
Is executed in the word process and BitmapAddDocument is a resource file
that will be called from the word process.
As I said, my object oriented implementation let me, depending on the
specific add-in application run the same "code". The code shown earlier will
be called from an outlook context as well as from word context but obviously
with different instances.
So when it comes to run wordEditor for a new mail, this code will be called
in word context to create buttons in word context.
I don't see why this then does not work!?
Thank you very much



"Ken Slovak - [MVP - Outlook]" wrote:

That sort of thing is what you need to mask the image. As I said before you
cannot use the Mask or Picture properties from an out-of-process call.

The example you cite isn't C++, it's VB 6 code. It just uses a lot of Win32
API calls.

To use that code you'd need to translate it into C# or VB.NET and take
especial care with the memory management and release calls so you don't leak
handles.

--
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


"Hichem S" wrote in message
...
Look at this C++ example :
http://support.microsoft.com/kb/288771
You see that it's a bit specific!
it's not only : button.mask = image!!
Thanks



  #8  
Old September 16th 08, 04:54 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Icons does not appear in a CommandBar : Catastrophic failure t

No matter how you try to avoid it, you are still going to run in an out of
process space if your code is running in an Outlook addin.

You would have to run all Word code in a Word addin (completely separate) to
avoid that, and then you'd have to figure out how to get the Word code to
execute what you want from the Outlook code.

The example is Word code, not Outlook code.

--
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


"Hichem S" wrote in message
...
Anyway...
You said : "WordMail is a subclassed version of msword.exe used by Outlook
as the email editor. As such it runs in the Word process space and not in
the
Outlook
process space. Picture and Mask take IPictureDisp objects, which cannot be
passed across process boundaries, therefore the exceptions."


In this example
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
Is executed in the word process and BitmapAddDocument is a resource file
that will be called from the word process.
As I said, my object oriented implementation let me, depending on the
specific add-in application run the same "code". The code shown earlier
will
be called from an outlook context as well as from word context but
obviously
with different instances.
So when it comes to run wordEditor for a new mail, this code will be
called
in word context to create buttons in word context.
I don't see why this then does not work!?
Thank you very much


  #9  
Old September 16th 08, 06:47 PM posted to microsoft.public.outlook.program_addins
Hichem S
external usenet poster
 
Posts: 13
Default Icons does not appear in a CommandBar : Catastrophic failure t

Don't you think that maybe wordmail is actually a simplistic version of word
process and that is why it's not able to handle everything word can! that's
why we have to workaround and find another solution to the problem we have
already a solution for!
Too much particular case. Is that possible?

The example is Word code, not Outlook code.

NB : the code I was talking about is the one shown in my first question in
this thread.



"Ken Slovak - [MVP - Outlook]" wrote:

No matter how you try to avoid it, you are still going to run in an out of
process space if your code is running in an Outlook addin.

You would have to run all Word code in a Word addin (completely separate) to
avoid that, and then you'd have to figure out how to get the Word code to
execute what you want from the Outlook code.

The example is Word code, not Outlook code.

--
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


"Hichem S" wrote in message
...
Anyway...
You said : "WordMail is a subclassed version of msword.exe used by Outlook
as the email editor. As such it runs in the Word process space and not in
the
Outlook
process space. Picture and Mask take IPictureDisp objects, which cannot be
passed across process boundaries, therefore the exceptions."


In this example
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
Is executed in the word process and BitmapAddDocument is a resource file
that will be called from the word process.
As I said, my object oriented implementation let me, depending on the
specific add-in application run the same "code". The code shown earlier
will
be called from an outlook context as well as from word context but
obviously
with different instances.
So when it comes to run wordEditor for a new mail, this code will be
called
in word context to create buttons in word context.
I don't see why this then does not work!?
Thank you very much



  #10  
Old September 16th 08, 08:26 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Icons does not appear in a CommandBar : Catastrophic failure t

No I don't think that's possible. I know that WordMail in Outlook 2003 and
earlier is a subclassing of msword.exe, which is not the case in Outlook
2007 where a special word dll is used for the editor.

Just accept it, for WordMail 2003 and earlier you cannot use Mask and
Picture from Outlook code. Period. It's documented all over the Internet.
Believe me or not, but that's the way things are.

--
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


"Hichem S" wrote in message
...
Don't you think that maybe wordmail is actually a simplistic version of
word
process and that is why it's not able to handle everything word can!
that's
why we have to workaround and find another solution to the problem we have
already a solution for!
Too much particular case. Is that possible?

The example is Word code, not Outlook code.

NB : the code I was talking about is the one shown in my first question in
this thread.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recover Mail? - Catastrophic HD failure kimdnw Outlook - Installation 2 December 5th 07 10:56 PM
Catastrophic Failure Mark Add-ins for Outlook 7 September 19th 07 06:36 PM
Error Message: Managed MAPI Service Catastrophic Failure BearlyCat Outlook - General Queries 0 November 27th 06 06:02 PM
Outlook 2007 Beta Catastrophic Failure Tibelian Outlook - General Queries 19 August 4th 06 01:28 AM
Catastrophic Failure while accessing Redemption.SafeMailItem.To and Recipients jisha Outlook and VBA 1 June 30th 06 05:48 PM


All times are GMT +1. The time now is 09:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.