Share via


HTMLTaskPaneObject 接口

代表与窗口关联的 Microsoft InfoPath 表单中的自定义任务窗格。

命名空间:  Microsoft.Office.Interop.InfoPath.SemiTrust
程序集:  Microsoft.Office.Interop.InfoPath.SemiTrust(位于 Microsoft.Office.Interop.InfoPath.SemiTrust.dll 中)

语法

声明
<GuidAttribute("096cd548-0786-11d1-95fa-0080c78ee3bb")> _
Public Interface HTMLTaskPaneObject _
    Inherits HTMLTaskPane, TaskPane
用法
Dim instance As HTMLTaskPaneObject
[GuidAttribute("096cd548-0786-11d1-95fa-0080c78ee3bb")]
public interface HTMLTaskPaneObject : HTMLTaskPane, 
    TaskPane

备注

此类型是用于 Coclass(托管代码需要此 Coclass 来实现 COM 互操作性)的包装。使用此类型来访问由此 Coclass 实现的 COM 接口。有关 COM 接口的信息(包括指向其成员说明的链接),请参阅HTMLTaskPane.

HTMLTaskPane 对象提供了许多属性和方法来使用 InfoPath 自定义任务窗格,并提供了 TaskPaneObject 对象的属性和方法。

可供 InfoPath 任务窗格使用的属性和方法由所使用的任务窗格的类型决定。如果 TaskPaneType 属性返回 0,则任务窗格为自定义任务窗格,并且由 HTMLTaskPane 对象提供可用的属性和方法。如果 TaskPaneType 属性返回任何其他值,则任务窗格为内置任务窗格,并且由 TaskPane 对象提供属性。

TaskPaneType 属性基于 XdTaskPaneType 枚举。这些枚举值还用作 TaskPanesCollection 集合的 Item 属性的参数,以返回对指定类型的任务窗格的引用。

备注

_XDocumentEventSink2_OnLoadEventHandler 事件期间不能调用 HTMLTaskPane 对象的属性和方法,因为视图在该事件发生时尚未加载,而且任务窗格与该视图相关联。

示例

在以下示例中,T:Microsoft.Office.Interop.InfoPath.SemiTrust.TaskPanesCollection 集合的 P:Microsoft.Office.Interop.InfoPath.SemiTrust.TaskPanes.Item(System.Object) 属性用于获取一个对代表自定义任务窗格的 T:Microsoft.Office.Interop.InfoPath.SemiTrust.TaskPaneObject 对象的引用。然后代码调用 HTMLTaskPane 对象的 Navigate 方法打开 HTML 文件。

public void CustomTaskPaneNavigation()
{
 // Get a reference to the custom task pane. It is always index [0] in the TaskPanes collection.   
 HTMLTaskPane oTaskPane = (HTMLTaskPane)thisXDocument.View.Window.TaskPanes[0];

 // Navigate based on url specified.
 oTaskPane.Navigate("taskpane2.html");
}

在以下示例中,TaskPanesCollection 集合的 Item 属性用于获取一个对代表自定义任务窗格的 TaskPaneObject 对象的引用。然后此代码使用 HTMLTaskPane 对象的 HTMLDocument 属性(由 TaskPane 对象继承)调用在自定义任务窗格的 HTML 代码中定义的脚本函数。

// Ensure View has loaded before trying to access the task pane.
if (thisXDocument.View != null)
{
 // Get a reference to the custom task pane.  It is always the 0-th
 // task pane in the TaskPanes collection.
 HTMLTaskPane custom = (HTMLTaskPane) thisXDocument.View.Window.TaskPanes[0];

 // Ensure that the task pane is completely loaded.
 if (custom != null && custom.HTMLDocument.readyState == "complete")
 {
  mshtml.IHTMLWindow2 window = custom.HTMLDocument.parentWindow;

  object[] args =  new object[] {"ViewID"};

  // call into script through CLR late binding mechanism
  window.GetType().InvokeMember(
   "SelectView",      // late bound method      
   System.Reflection.BindingFlags.InvokeMethod |   // binding flags
   System.Reflection.BindingFlags.DeclaredOnly | 
   System.Reflection.BindingFlags.Public | 
   System.Reflection.BindingFlags.Instance,     
   null,        // binder object
   window,        // target object
   args);
 }
}

另请参阅

引用

HTMLTaskPaneObject 成员

Microsoft.Office.Interop.InfoPath.SemiTrust 命名空间