HtmlTaskPane.HtmlWindow property

Gets a reference to the MSHTML IHTMLWindow2 interface for working with the HTML document of a custom task pane.

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

Syntax

'Declaration
Public MustOverride ReadOnly Property HtmlWindow As Object
    Get
'Usage
Dim instance As HtmlTaskPane
Dim value As Object

value = instance.HtmlWindow
public abstract Object HtmlWindow { get; }

Property value

Type: System.Object
An IHTMLWindow2 object associated with HTML file of the custom task pane.

Exceptions

Exception Condition
SecurityException

The form template is not configured for Full Trust using the Security and Trust category of the Form Options dialog box.

Remarks

Using the HtmlWindow property, you can call scripting functions contained in the HTML code of the task pane from the primary form code, manipulate the HTML code of the task pane, and work with any of the properties and methods that the IHTMLWindow2 interface provides.

Note

The HtmlWindow property provides the same functionality as the HtmlDocument property, but it is only available when using fully trusted forms. If the form is not fully trusted, you can use the HtmlDocument property instead.

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.

Examples

In the following example, the HtmlWindow property of the HtmlTaskPane class is used to set a reference to the IHTMLWindow2 object of the custom task pane of a fully trusted form. Then the code calls the TaskPaneSwitchView custom function that is defined in the HTML code of the custom task pane.

   // Get a reference to the custom task pane. It is always index [0]
   // in the TaskPanes collection.
   HtmlTaskPane custom = (Microsoft.Office.InfoPath.HtmlTaskPane)
      this.CurrentView.Window.TaskPanes[0];

   // Get a reference to the parent window of the task pane.
   IHTMLWindow2 window = (IHTMLWindow2)custom.HtmlWindow;

   // Call into script through CLR late binding mechanism.
   window.GetType().InvokeMember(
      "TaskPaneSwitchView",      // late bound method name.
      System.Reflection.BindingFlags.InvokeMethod | // binding flags
      System.Reflection.BindingFlags.DeclaredOnly |
      System.Reflection.BindingFlags.Public |
      System.Reflection.BindingFlags.Instance,
      null,     // binder object
      window,   // target object
      null);   // method arguments
   ' Get a reference to the custom task pane. It is always index (0)
   ' in the TaskPanes collection.
   Dim custom As HtmlTaskPane = _
      DirectCast(Me.CurrentView.Window.TaskPanes(0), _
      Microsoft.Office.InfoPath.HtmlTaskPane)

     ' Get a reference to the parent window of the task pane.
      Dim window As IHTMLWindow2 = DirectCast(custom.HtmlWindow, _
         IHTMLWindow2

     ' Call into script through CLR late binding mechanism.
     window.GetType().InvokeMember( _
      "TaskPaneSwitchView", _
      System.Reflection.BindingFlags.InvokeMethod Or _
      System.Reflection.BindingFlags.DeclaredOnly Or _
      System.Reflection.BindingFlags.Public Or _
      System.Reflection.BindingFlags.Instance, _
      Nothing, _
      window, _
      Nothing)

See also

Reference

HtmlTaskPane class

HtmlTaskPane members

Microsoft.Office.InfoPath namespace