2010-03-03 16 views
4

我在理解Outlook術語(CommandBarPopup,CommandBarButton等)方面遇到了一些麻煩,因此請耐心等待。在C#中的Outlook插件 - 如何添加新郵件中的按鈕/組(0123簽名旁)

我想創建幾件事情:

  1. 我想創建新組(或只是按鈕,但我讀這是不可能的按鈕添加到現有組帶)新郵件功能區中的簽名/添加附件旁邊的電子郵件。它必須以與Signature相同的方式工作,所以當你按下它時,它會顯示幾個選項。我如何創建它?

  2. 我想重寫一個按鈕「NEW」(您可以選擇要發送新郵件,預約或做其他事情),以便當您在主窗口中時按下向下箭頭到新的按鈕,你可以選擇我將添加的選項之一?這可能嗎?我該怎麼做?

  3. 我有一些代碼,添加菜單在主窗口

    private void AddMenuBar() { 
        try { 
         //Define the existent Menu Bar 
         menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; 
         //Define the new Menu Bar into the old menu bar 
         newMenuBar = (Office.CommandBarPopup) menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false); 
         //If I dont find the newMenuBar, I add it 
         if (newMenuBar != null) { 
          newMenuBar.Caption = "Test"; 
          newMenuBar.Tag = menuTag; 
          buttonOne = (Office.CommandBarButton) newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); 
          buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; 
          buttonOne.Caption = "Test Button"; 
          //This is the Icon near the Text 
          buttonOne.FaceId = 610; 
          buttonOne.Tag = "c123"; 
          //Insert Here the Button1.Click event  
          buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonOneClick); 
          newMenuBar.Visible = true; 
         } 
        } catch (Exception ex) { 
         //This MessageBox is visible if there is an error 
         System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString(), "Error Message Box", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
        } 
    } 
    

我想在buttonOne下添加子所以當我按下它新的子菜單打開。我如何實現這一目標?

回答

3
  1. 是不是在可能的OOM不會公開此類型的按鈕:(即使MS使用它。你可以儘管隱藏按鈕組,然後通過添加標準命令創建自己的「同類」組,還挺給你同樣的事情

編輯:XML使用它的Visible屬性及其idMso隱藏標準行動組..

<?xml version="1.0" encoding="UTF-8"?> 
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" loadImage="GetImage"> 
    <ribbon> 
    <tabs> 
     <tab idMso="TabReadMessage"> 
     <group idMso="GroupActions" visible="false"> 
     </group> 

     <group id="newactionsgroup" label="Actions" insertAfterMso="GroupActions"> 
      <button idMso="Delete" size="large"/> 
      <button id="MoveToFolder" imageMso="MoveToFolder" size="large" label="Move To Folder" onAction="myMoveToFolder" /> 
      <button idMso="CreateMailRule" size="large"/> 
      <menu idMso="OtherActionsMenu" size="large"/> 
     </group> 
    </tab> 
    </tabs> 
    </ribbon> 
</customUI> 
  • 根本不可能的,雖然你可以再次隱藏現有的butto n並創建一個類似的井位置表單!
  • 3.創建您的buttonOne作爲的CommandBarPopup

    +0

    你有關於如何隱藏按鈕組,並添加自己的(我不知道如何創建GRP和那些按鈕)的例子。 – MadBoy 2010-03-09 08:16:31

    +0

    已經添加了一些功能區xml讓你隱藏標準組並自行修復。 – 76mel 2010-03-09 14:06:19

    +0

    謝謝,雖然我會慷慨地花了一些時間,直到我得到它的工作;)我真的需要閱讀一些關於它的書籍:) – MadBoy 2010-03-09 20:07:09

    1

    我不知道如果這是你在找什麼在你的第二個問題,但我設法自定義菜單項添加到「新」下拉按鈕用下面的代碼:

    private void AddButtonToNewDropdown() 
        { 
         Office.CommandBar commandBar = this.Application.ActiveExplorer().CommandBars["Standard"]; 
         Office.CommandBarControl ctl = commandBar.Controls["&New"]; 
         if (ctl is Office.CommandBarPopup) 
         { 
          Office.CommandBarPopup newpopup = (Office.CommandBarPopup)ctl; 
          commandBarButton = (Office.CommandBarButton)newpopup.Controls.Add(1, missing, missing, missing, true); 
          commandBarButton.Caption = "My custom button"; 
          commandBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick); 
         } 
    
        } 
    
    +0

    太好了!儘管「&New」按鈕必須進行本地化才能工作,但它的工作方式類似於魅力。偉大的發現。您是否碰巧知道如何爲該按鈕創建子菜單,以及如何重新排列新菜單,以便我可以將新按鈕放在頂部? – MadBoy 2010-03-10 18:01:57

    +0

    另外我如何刪除這樣創建的按鈕? :) – MadBoy 2010-03-10 18:07:00

    相關問題