H
Hichem S
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.msoControlButton, 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(BitmapAddDocument);
myButton .Mask = AxHelper.GetIPictureDispFromImage(BitmapAddDocumentMask);
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);
}
}
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.msoControlButton, 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(BitmapAddDocument);
myButton .Mask = AxHelper.GetIPictureDispFromImage(BitmapAddDocumentMask);
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);
}
}