我在理解Outlook术语(CommandBarPopup,CommandBarButton等)方面遇到了一些问题,就像Outlook中的内容一样,请耐心等待。
我想创建几件事:
我想在消息功能区中的签名/添加附件旁边的新邮件上创建新组(或只是按钮,但我读到它无法在功能区中向现有组添加按钮)。它必须以与Signature相同的方式工作,因此当您按下它时,它会显示几个选项。我该如何创建它?
我想覆盖“NEW”按钮(您可以选择要发送新邮件,预约或执行其他操作),以便在按下向下箭头时进入主窗口在新按钮旁边,您可以选择我要添加的选项之一?这可能吗?我该怎么办?
我有一些代码可以在主窗口中添加菜单
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下添加子菜单,所以当我按下它时,新的子菜单会打开。我如何实现这一目标?
答案 0 :(得分:3)
编辑: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>
3.创建buttonOne作为CommandBarPopup
答案 1 :(得分: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);
}
}