Export (0) Print
Expand All

HTMLTaskPaneObject interface

Represents a custom task pane in a Microsoft InfoPath form that is associated with a window.

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

[GuidAttribute("096cd548-0786-11d1-95fa-0080c78ee3bb")]
public interface HTMLTaskPaneObject : HTMLTaskPane, 
	TaskPane

This type is a wrapper for a coclass that is required by managed code for COM interoperability. Use this type to access the members of the COM interface implemented by this coclass. For information about the COM interface, including a link to descriptions of its members, seeHTMLTaskPane.

The HTMLTaskPane object provides a number of properties and methods for working with the InfoPath custom task pane, and it provides properties and methods of the TaskPaneObject object.

The properties and methods that are available for an InfoPath task pane are determined by the type of task pane that you are working with. If the TaskPaneType property returns 0, the task pane is a custom task pane and the properties and methods that are available are provided by the HTMLTaskPane object. If the TaskPaneType property returns any other value, the task pane is a built-in task pane and the properties are provided by the TaskPane object.

The TaskPaneType property is based on the XdTaskPaneType enumeration. These enumerated values are also used as arguments to the Item property of the TaskPanesCollection collection for returning a reference to a specified type of task pane.

NoteNote

The properties and methods of the HTMLTaskPane object cannot be called during an _XDocumentEventSink2_OnLoadEventHandler event because the view is not yet loaded when this event occurs, and task panes are associated with the view.

In the following example, the P:Microsoft.Office.Interop.InfoPath.SemiTrust.TaskPanes.Item(System.Object) property of the T:Microsoft.Office.Interop.InfoPath.SemiTrust.TaskPanesCollection collection is used to get a reference to the T:Microsoft.Office.Interop.InfoPath.SemiTrust.TaskPaneObject object that represents the custom task pane. The code then calls the Navigate method of the HTMLTaskPane object to open an HTML file.

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");
}

In the following example, the Item property of the TaskPanesCollection collection is used to get a reference to the TaskPaneObject object that represents the custom task pane. The code then calls a scripting function defined in the HTML code of the custom task pane using the HTMLDocument property of the HTMLTaskPane object, which is inherited by the TaskPane object.

// 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);
 }
}

Community Additions

ADD
Show:
© 2014 Microsoft