2012-08-12 66 views
0

我目前正在爲Outlook 2010的AttachmentContextMenu開發一個簡單的「Open With ...」菜單項,因爲根據「內容」,我想使用不同的程序啓動相同的文件類型。Outlook 2010:AttachmentContextMenu:添加項目

所以 - 根據示例 - 我需要通過在「AttachmentContextMenuDisplay」事件中修改它來擴展上下文菜單。所以,我寫這個:

private void ThisAddIn_Startup(object sender, System.EventArgs e) 
    { 
     //add Handler, that watches AttachmentMentuOpening. 
     Application.AttachmentContextMenuDisplay += new Outlook.ApplicationEvents_11_AttachmentContextMenuDisplayEventHandler(Application_AttachmentContextMenuDisplay); 
    } 

    void Application_AttachmentContextMenuDisplay(Office.CommandBar CommandBar, Outlook.AttachmentSelection Attachments) 
    { 
     Office.CommandBarControl button = (CommandBarButton)CommandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true); 
     button.Caption = "OpenWith..."; 
     button.DescriptionText = "Open with certain application"; 
    } 

該處理程序被觸發並執行 - 但沒有添加菜單項。如果我循環控制集合後添加項目 - 它在那裏。

現在奇怪的事情:如果我在我的事件處理程序中調用CommandBar.ShowPopup()方法,將顯示按鈕,但是.c。然後該方法繼續(和終止)以後,使被再次顯示的菜單...

截圖與上面的代碼:

http://open-host.de/?modul=bildhosting&view=9519869938

截圖添加了 「CommandBar.ShowPopup();」在處理程序結束時。

http://open-host.de/?modul=bildhosting&view=04fa35fdcd

而且我不知道,爲什麼那裏有在Appearence有區別嗎?

任何想法?

回答

相關問題