Isabella
---- I fell upon the thorn of life, I bleed.
posts - 18,  comments - 14,  trackbacks - 0

如果你用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 !");
        }

posted on 2006-07-28 10:22 李昀璟 阅读(1982) 评论(2)  编辑 收藏

FeedBack:
2006-11-11 19:25 | james.dong      
想问下楼主:
在word中可以添加自定义右键菜单吗?

 回复 引用 查看   
2008-05-31 07:20 | Fan Lee[未注册用户]
do some one know how to do things to the folder tree view in the outlook explorer navigation pane:

(1) change the folder icon
(2) add a custom menu item in the folder context menu

Thanks!

 回复 引用