我在为 Outlook 中的自定义上下文菜单项设置图像时遇到问题。我强烈要求使用我提供的自定义图像。
这就是我现在的做法:
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 bit)。
问题是我的新项目的 outlook 上下文菜单中没有图像。按钮出现,它做了我想要它做的事,但没有显示图像。并且不会抛出异常。那会是什么?
最佳答案
尝试设置 contextButton.Style=MsoButtonStyle.msoButtonIconAndCaption
关于c# - Outlook 2007/2010 上下文菜单项图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5496969/