创建窗体区域
This topic lists the considerations and steps for creating a form region.
There are different types of form regions, depending on how you want to customize the form and where you place the form region in the form. A form region can add extra user interface to the default page or add an extra page to a standard form. Or, it can replace the default page of a standard form, or replace the entire standard form, resulting in a new form for a derived message class. 使用标记在窗体区域清单 XML 文件中指定窗体区域的类型, <formRegionType>
如步骤 7 中所述。 Aside from this, the means to create and design these various types of form regions is identical:
使用窗体设计器创建和设计布局(步骤 1 到 5)
将窗体区域另存为 Outlook Form Storage (.OFS) 文件(步骤 6)
创建窗体区域清单 XML 文件,为 Microsoft Outlook 指定有关窗体区域的其他详细信息(步骤 7)
为邮件类注册窗体区域(步骤 9)
重新启动 Outlook 后,将可以使用该窗体区域。 或者,可以创建窗体区域和窗体区域清单 XML 文件,使用外接程序扩展窗体区域,并以编程方式注册窗体区域。 安装加载项时,该加载项还会安装包含该窗体区域的窗体。
有关详细信息,请参阅使用加载项扩展窗体区域。
下列过程详细说明了使用窗体设计器(不含加载项)创建窗体区域的步骤。
在 "开发工具" 选项卡上的 "自定义窗体" 组中,单击 "设计窗体"。
在 9 个标准 Outlook 窗体中,选择最符合您的要求的一个窗体: 约会、 联系人、 日记条目、 会议要求、 邮件、 公告、 RSS 文章、 任务和 任务要求。
自定义窗体时,最开始总是使用一个标准窗体作为模板。 选择标准窗体时,应考虑以下事项:
与表单关联的操作,例如,是否将表单发送给其他人,在这种情况下,应选择“邮件”窗体。
表单中所需的字段类型,例如,它们是否主要是特定于联系人的字段。
计划自定义的范围。 是否只需要向标准窗体默认页的底部添加额外控件就可以满足要求? 是否需要额外的自定义页面? 或者,是否需要大幅度修改用户界面以便在新建窗体时更加方便? 请注意,仅当为派生邮件类指定窗体时,才可以替换该窗体上的页面。
在窗体设计器的 "设计" 组中,在 "开发人员" 选项卡中单击 "新建窗体区域"。
请注意,任何类型的窗体区域在窗体设计器中都作为单独的页面打开。 在运行时,将按您在窗体区域清单 XML 文件中指定的方式显示窗体区域,如步骤 7 中所述。
通过将控件从工具箱拖放到窗体区域并将其绑定到适当的字段来设计窗体区域的布局。
与自定义窗体页面相似,自定义窗体区域包括定义自定义字段,使用工具箱插入控件,以及使用字段选择器将这些控件与字段绑定到一起。 有关详细信息,请参阅自定义窗体中的控件以及演练:向窗体上的现有页面添加窗体区域中的“设计窗体区域”一节。 可以选择使用加载项来以编程方式设计控件的事件。
单击 "保存区域",然后在 "设计" 组中单击 "保存窗体区域" 以保存窗体区域的布局。 保存的窗体区域布局文件带有 .OFS 扩展名。
使用 XML 编辑器(如记事本)创建窗体区域清单 XML 文件。
您必须为每个窗体区域指定 XML,以告知 Outlook 如何显示它及其支持的操作。 XML 必须针对窗体区域清单架构 (进行验证,有关架构的详细信息,请参阅 MSDN 库) 中的 Microsoft Outlook 2010 XML 架构参考。 该架构支持许多元素,例如下面枚举的更常用元素:
The <addin> tag specifies the ProgID of the add-in that manages the form region and provides storage for it. You should only specify this tag if you use an add-in to create and manage the form region.
The <customActions> tag that specifies the actions supported by the form region, for example, reply and forward.
The <displayAfter> tag specifies the form region that precedes the current form region in the same form. This information defines the initial order of multiple adjoining form regions or multiple separate form regions in the same form.
The <formRegionType> tag specifies whether the form region is an additive form region (adjoining or separate form region), or is a replacement or replace-all form region (replacing the default page or the entire standard form and resulting as a new form for a derived message class).
The <layoutFile> tag specifies the location of the .OFS file, if one exists. Note that any file paths in the .OFS file, including this file path, can be specified as a relative path to the location of the form region manifest XML file specified in the registry. However, also note that UNC paths are not supported. If you use an add-in to create and manage the form region, you must specify the <addin> tag but not this tag.
The <name> tag specifies the name for the form region used only in code.
标题<>标记指定“操作”菜单和“选择窗体”对话框中单独窗体区域的显示名称。
The <icons> tag specifies the location of icon files.
注意
[!注释] 默认情况下,图标文件位于与窗体区域清单 XML 文件相同的文件夹中或相对于此文件夹的一个位置。 您也可以为图标文件指定一个完整路径,例如:
<icons><default>c:\myicon.ico</default></icons>
或资源文件的完整位置,例如:<icons><unread>c:\myresource.dll,101</unread> </icons>
,它会在资源文件 c:\myresource.dll 中加载图标资源 101。 但是,不要使用指定外接程序程序集文件中嵌入的图标的隐式约定。 例如:<icons><read>,102</read></icons>
将不受支持,并且不会在外接程序 dll 中加载图标资源 102。关闭 Outlook。
在 Windows 注册表中注册窗体区域,指定此窗体区域适用于的消息类,以及窗体区域清单 XML 文件的完整文件路径。
在 Windows 注册表中的 HKEY_CURRENT_USER 或 HKEY_LOCAL_MACHINE 配置单元下注册窗体区域。 例如,IPM 的累加窗体区域 。 当前用户的联系人消息类应在同一密钥下注册, HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\FormRegions\IPM.Contact。 请注意,将在应用于 IPM 的所有窗体中为当前用户显示窗体区域 。Contact 和派生自 IPM 的任何消息类 。联系人。 如果希望窗体区域仅用于 IPM。联系 并且不希望派生邮件类使用该窗体区域,可以使用窗体区域清单 XML 文件中的 <exactMessageClass> 标记指定此项。
启动 Outlook。 打开在步骤 9 中为窗体区域指定的邮件类的项时,会在检查器中看到窗体区域。
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。