c# - Outlook 2007/2010 上下文菜单项图片

标签 c# contextmenu outlook-addin

我在为 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/

相关文章:

java - Eclipse 菜单管理器 : get ImageDescriptor of Image?

javascript - TippyJS-React : how to open context-menu on right-click

c# - 获取深度嵌入的 XML 元素值

c# - 更新失败 - Entity Framework Core

c# - asp c# 中的结构化数据 JSON ld

macos - 系统正在将不需要的项目添加到我的应用程序中的自定义上下文菜单中

outlook - 我可以将自定义图标添加到 "outlook"项目吗?

c# - 如何在VS 2010中开发MS Outlook插件?

vba - 自动将电子邮件签名插入 Outlook session 邀请

c# - 如何为我的 AdomdConnection 设置连接超时?