HtmlTaskPane.HtmlWindow プロパティ
カスタム作業ウィンドウの HTML ドキュメントで作業するための MSHTML IHTMLWindow2 インターフェイスへの参照を取得します。
名前空間: Microsoft.Office.InfoPath
アセンブリ: Microsoft.Office.InfoPath (Microsoft.Office.InfoPath.dll)
構文
'宣言
Public MustOverride ReadOnly Property HtmlWindow As Object
Get
'使用
Dim instance As HtmlTaskPane
Dim value As Object
value = instance.HtmlWindow
public abstract Object HtmlWindow { get; }
プロパティ値
型: System.Object
カスタム作業ウィンドウの HTML ファイルに関連付けられている IHTMLWindow2 オブジェクト。
例外
例外 | 条件 |
---|---|
SecurityException | フォーム テンプレートが、[フォームのオプション] ダイアログ ボックスの [セキュリティと信頼] カテゴリを使用して [完全信頼] として構成されていません。 |
解説
HtmlWindow プロパティを使用すると、作業ウィンドウの HTML コードを扱いながら、プライマリ フォーム コードから作業ウィンドウの HTML コードに記述されているスクリプト関数を呼び出したり、IHTMLWindow2 インターフェイスが提供する任意のプロパティとメソッドで作業することができます。
注意
HtmlWindow プロパティは、機能的には HtmlDocument プロパティと同じですが、完全に信頼されたフォームを使用する場合にのみ使用できます。フォームが完全に信頼されていない場合は、代わりに HtmlDocument プロパティを使用できます。
このメンバーには、[フォームのオプション] ダイアログ ボックスの [セキュリティ] または [信頼] カテゴリを使用して、完全な信頼を与えられて実行するように構成されたフォーム テンプレートから開かれたフォームのみがアクセスできます。このメンバーは、直接の呼び出し側の完全な信頼が必要であり、部分的に信頼されたコードでは使用できません。詳細については、MSDN の「部分信頼コードからのライブラリの使用」を参照してください。
この型またはメンバーには、Microsoft InfoPath Filler で開かれたフォームを実行中のコードからのみアクセスできます。
例
次の例では、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)