4

我在理解 Outlook 术语(CommandBarPopup、CommandBarButton 等)时遇到了一些问题,比如 Outlook 中的内容,所以请耐心等待。

我想创造几件事:

  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 下添加子菜单,所以当我按下它时会打开新的子菜单。我该如何做到这一点?

4

2 回答 2

3
  1. 这是不可能的,因为 OOM 不公开这种类型的按钮 :( 即使 MS 使用它。你可以隐藏一个按钮组,然后通过添加标准命令创建你自己的“相似”组,有点给你同样的东西。

编辑:XML 隐藏标准操作组 .. 使用它的可见属性和它的 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>
  1. 尽管您可以再次隐藏现有按钮并使用位置良好的表单创建类似的东西,但这根本不可能!

3.将您的 buttonOne 创建为 CommandBarPopup

于 2010-03-08T15:16:48.530 回答
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);
        }

    }
于 2010-03-10T16:39:56.950 回答