2011-03-31 27 views
1

我有一个问题,将图像设置为Outlook中的自定义上下文菜单项。我有强烈的要求使用我提供的自定义图像。
这就是我如何做它现在:
Outlook 2007/2010上下文菜单项图片

Application.ItemContextMenuDisplay += ApplicationItemContextMenuDisplay; 

...

private void ApplicationItemContextMenuDisplay(CommandBar commandBar, Selection selection) 
    { 
     var contextButton = commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true) as CommandBarButton; 
     contextButton.Picture = ImageConverter.ImageToPictureDisp(Resources.ContextMenuIcon); 
     contextButton.Visible = true; 
     contextButton.Caption = Resources.ArchiveMail; 
     contextButton.Click += ArchiveButtonClicked; 
    } 

我的图像转换器看起来是这样的:

public class ImageConverter : AxHost 
{ 
    public ImageConverter() : base("59EE46BA-677D-4d20-BF10-8D8067CB8B33") 
    { 
    } 

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

我是形象使用的是bmp(16 * 16,8位)。
问题是,在我的新项目的Outlook上下文菜单中没有图像。该按钮出现,它做我想要它做的,但没有图像显示。并没有抛出异常。那可能是什么?

回答

4

试用套装contextButton.Style=MsoButtonStyle.msoButtonIconAndCaption

+0

非常感谢。它现在有效。 – Proton 2011-03-31 08:29:34