HtmlTaskPane.HtmlWindow 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取对 MSHTML IHTMLWindow2 接口的引用,以便使用自定义任务窗格的 HTML 文档。
public:
abstract property System::Object ^ HtmlWindow { System::Object ^ get(); };
public abstract object HtmlWindow { get; }
member this.HtmlWindow : obj
Public MustOverride ReadOnly Property HtmlWindow As Object
属性值
与自定义任务窗格的 HTML 文件关联的 IHTMLWindow2 对象。
例外
没有使用“表单选项”对话框的“安全和信任”类别将表单模板配置为“完全信任”。
示例
在以下示例中,HtmlTaskPane 类的 HtmlWindow 属性用于设置对完全信任表单的自定义任务窗格的 IHTMLWindow2 对象的引用。 然后,代码将调用在自定义任务窗格的 HTML 代码中定义的 TaskPaneSwitchView 自定义函数。
// 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)
注解
使用 HtmlWindow 属性,可以从主要表单代码中调用包含在任务窗格的 HTML 代码中的脚本函数,操纵任务窗格的 HTML 代码,并可以使用 IHTMLWindow2 接口提供的任意属性和方法。
注意: HtmlWindow 属性提供与 属性相同的功能 HtmlDocument ,但仅在使用完全受信任的表单时可用。 如果表单没有受到完全信任,可以改用 HtmlDocument 属性。
只能由从表单模板打开的表单访问此成员,已使用“表单选项”对话框“安全和信任”类别将该模板配置为以完全信任状态运行。 此成员要求直接调用方的完全信任并且不能由部分信任的代码使用。 有关更多信息,请参阅 MSDN 上的“使用部分信任的代码中的库”。
可以通过 Microsoft InfoPath Filler 中打开的表单中运行的代码访问此类型或成员。