zoukankan      html  css  js  c++  java
  • 如何对Outlook添加右键菜单


    // 如果你用VSTO2005开发有以下办法添加右键菜单:
    Outlook.ExplorerClass _Explorer = null;
    Office.CommandBars _CommandBars = null;
    object _Missing = System.Reflection.Missing.Value;
    Office.CommandBarButton _ContextMenuButton = null;
    private void ThisApplication_Startup(object sender, System.EventArgs e)
    {

    _Explorer = (Outlook.ExplorerClass)this.ActiveExplorer();
    _CommandBars = _Explorer.CommandBars;
    _CommandBars.OnUpdate += new Microsoft.Office.Core._CommandBarsEvents_OnUpdateEventHandler(_CommandBars_OnUpdate);


    }
    void _CommandBars_OnUpdate()
    {
    foreach (Office.CommandBar bar in _CommandBars)
    {
    if (bar.Name == "Context Menu")
    {
    // we found the context menu
    Office.MsoBarProtection oldProtection = bar.Protection;
    bar.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoProtection;
    _ContextMenuButton = (Office.CommandBarButton)bar.Controls.Add(Office.MsoControlType.msoControlButton, 1, _Missing, _Missing, true);
    _ContextMenuButton.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption;
    _ContextMenuButton.TooltipText = "Isabella's Context menu....";
    _ContextMenuButton.BeginGroup = true;
    _ContextMenuButton.Caption = "Click me...";
    _ContextMenuButton.Visible = true;
    _ContextMenuButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(_ContextMenuButton_Click);
    bar.Protection = oldProtection;
    }
    }
    }
    void _ContextMenuButton_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
    {
    MessageBox.Show("Hey, you clicked the Contextbutton !");
    }

    源:http://www.cnblogs.com/Isabella/articles/contextMenu.html



    返回导读目录,阅读更多随笔



    分割线,以下为博客签名:

    软件臭虫情未了
    • 编码一分钟
    • 测试十年功


    随笔如有错误或不恰当之处、为希望不误导他人,望大侠们给予批评指正。

  • 相关阅读:
    ubuntu安装RabbitMQ
    pycharm中引入相对路径错误
    python之pip
    ubuntu安装django
    ubuntu16安装python3.7
    ubuntu上用源码进行一键安装mysql
    tar命令
    linux之bc命令
    linux源码安装
    ubuntu安装搜狗输入法后无法使用goland的快捷键 ctrl+alt+B
  • 原文地址:https://www.cnblogs.com/08shiyan/p/2194040.html
Copyright © 2011-2022 走看看