zoukankan      html  css  js  c++  java
  • Outlook2007 addin开发必读菜单定制篇

    介绍
    自从微软开始推出VSTO以后,我们就更容易在此基础上面开发Add-in程序。对VSTO的介绍,大家可以看看这篇文章:VSTO简介及发展。本文例子是基于VSTO 3.0上进行的开发。
    本文是在微软《Customizing the Ribbon in Outlook 2007》 基础上加入自己的实践和想法,供大家参考。

    这段文字是来至于:
    Http://msdn.microsoft.com/zh-cn/library/bb226712(en-us).aspx
    Customizing the Ribbon in Outlook 2007

    The Microsoft Office Fluent user interface (UI) is the terminology used to describe the new UI for the 2007 Microsoft Office system. The Ribbon is a component of the Microsoft Office Fluent UI.
    Ribbon是新的Microsoft办公软件舒适?的界面组件。

    Unlike other applications in the 2007 Microsoft Office system, such as Microsoft Office Word, Microsoft Office Excel, and Microsoft Office PowerPoint, which rely exclusively on the Ribbon, Microsoft Office Outlook 2007 uses both the Ribbon and command bars. Additionally, Outlook does not support document-level customizations of the Ribbon. You can customize the Ribbon only by implementing the IRibbonExtensibility interface in an Outlook add-in.
    OutLook有区别于其他Office程序(word,excel,powerPoint),它不像它们完成依赖于Ribbon,outLook 2007同时存在两种样式菜单-Ribbon和command bars。此外,Outlook 2007不支持页面级(关于页面级的说明请参看:VSTO简介及发展)Ribbon的定制。你只能通过实现一个IRibbonExtensibility接口在Outlook add-in项目来定制Ribbon。

     

    一个OutLook 2007 add-in项目只能实现一个Ribbon

    一个Ribbon可以有多个Ribbon Tab。
    Ribbon对象是怎么跟Add-in结合起来的?
    在add-in class中通过下面任意方法Hook上的。
    方法一:

    protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() { return new Ribbon(); } 

    方法二:

    private Ribbon _ribbon;
    protected override object RequestService(Guid serviceGuid)
    {
    
    if (serviceGuid==typeof(Office.IRibbonExtensibility).GUID)
    {
    if (_ribbon == null)
    _ribbon = new Ribbon();
    return _ribbon;
    }
    return base.RequestService(serviceGuid);
    }
    一个Ribbon可以出现在多个Item窗体上(什么是item?Message,contact,appointment 等等)如果只让Ribbon出现某几个Item窗体上?
    #region IRibbonExtensibility Members
    public string GetCustomUI(string ribbonID) { return GetResourceText("emailFinder.Ribbon.xml"); }
    #endregion
    
    //如果只让它出现在撰写邮件的窗体上
    public string GetCustomUI(string ribbonID) {
    if(ribbonID=="Microsoft.Outlook.Mail.Compoase") return GetResourceText("emailFinder.Ribbon.xml");
    else
    return string.Empty; }
     
    *注意:ribbonID你可以在vs2008 ribbon组件视图设计器中得到
    image 
     
    ribbon视觉设计项的作用?
    image 
     

    它的作用是完成视觉设计并导出成为ribbon的标准XML。
    而代码工作都是在ribbon类中手工完成

    In the main application window, Outlook displays the command bars that are familiar to users of earlier versions of Microsoft Office.
    在OutLook 2007主窗体中,我们使用以前版本很像是的command bars

    In item windows, such as a mail message window where authoring is the central user experience, Outlook uses the new Ribbon.
    在子项窗体里,比如邮件消息窗体(其编辑功能是用户体验核心),Outlook使用新的Ribbon

    To provide the best authoring experience for end-users, Outlook item windows display item-specific Ribbons. From an object model perspective, an Outlook item window is an Inspector object. If you have existing code that uses the object returned by the Inspector.CommandBars property to customize command bars for standard or custom item types, this article describes how Ribbon extensibility improves your existing customizations of command bars for an Outlook Inspector.
    对于更佳的需要客户体验编辑窗体来说,我们使用Ribbon。它是观察者(Inspector)对象,通过Inspector.CommandBars 属性来获取定制的菜单。

    The main application window, known as an Explorer object, still uses command bars introduced in earlier versions of Office.
    For an Outlook Explorer, you continue to use the object returned by the Explorer.CommandBars property to customize the Outlook window. As a prerequisite for this article, you must know how to write code for the Office CommandBars object model so that I will not spend much time discussing the CommandBars object model.

    对主窗体来说,是一个浏览对象,而且可以继续使用Explorer.CommandBars属性来取得command bars对象。而我也不用花大量时间来介绍CommandBars对象模型。

    There are several excellent blogs and technical articles that discuss Ribbon extensibility in detail on MSDN. For a comprehensive view of all aspects of the Ribbon, a must-read is Jensen Harris: An Office User Interface Blog. For developer information about Ribbon extensibility for tabs, groups, and controls, see Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3), Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3), and Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3) by Frank Rice. I urge you to view these references because I do not repeat the comprehensive listing of Ribbon XML Schema and callback signatures that you can find on MSDN. In this article, I focus on what you have to know about the Outlook implementation of the Ribbon.

    介绍了在主窗体和item窗体后,我再说一下上下文菜单的定制,也就是通常说的右键菜单。

    image

    通过观察和阅读其他文章,我认为上下文菜单是可以通过Explorer.CommandBars获取, 理由是在主窗体中Outlook 2007依然使用以前的菜单模型。

  • 相关阅读:
    获取文字宽高
    jni中的参数含义
    jni开发中的常见错误
    指针只需要记住一点
    Eclipse web项目引用其它项目时的部署问题
    关于JAVA日志
    去掉Mybatis Generator生成的一堆 example
    怎样给Eclipse添加一个Xml模板
    Junit很少出现的一个问题 No tests found matching ...
    出现异常:Unsupported major.minor version
  • 原文地址:https://www.cnblogs.com/king_astar/p/1592398.html
Copyright © 2011-2022 走看看