WebBrowser.DetachSink メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


アンマネージ WebBrowser ActiveX コントロールを使用した OLE 開発に慣れていれば、このメソッドを利用して Windows フォームの WebBrowser コントロールの機能を拡張できます。このコントロールは ActiveX コントロールのマネージ ラッパーです。この拡張性を利用して、ラッパー コントロールでは提供されない ActiveX コントロールのイベントを実装できます。

WebBrowser から派生したクラスでこのメソッドを使用し、標準の WebBrowser イベントを OLE DWebBrowserEvents2 の NavigateError イベントで補完する方法を次のコード例に示します。
コード全体については、「CreateSink」を参照してください。
Private cookie As AxHost.ConnectionPointCookie Private helper As WebBrowser2EventHelper <PermissionSetAttribute(SecurityAction.LinkDemand, _ Name := "FullTrust")> Protected Overrides Sub CreateSink() MyBase.CreateSink() ' Create an instance of the client that will handle the event ' and associate it with the underlying ActiveX control. helper = New WebBrowser2EventHelper(Me) cookie = New AxHost.ConnectionPointCookie( _ Me.ActiveXInstance, helper, GetType(DWebBrowserEvents2)) End Sub <PermissionSetAttribute(SecurityAction.LinkDemand, _ Name := "FullTrust")> Protected Overrides Sub DetachSink() ' Disconnect the client that handles the event ' from the underlying ActiveX control. If cookie IsNot Nothing Then cookie.Disconnect() cookie = Nothing End If MyBase.DetachSink() End Sub
AxHost.ConnectionPointCookie cookie; WebBrowser2EventHelper helper; [PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")] protected override void CreateSink() { base.CreateSink(); // Create an instance of the client that will handle the event // and associate it with the underlying ActiveX control. helper = new WebBrowser2EventHelper(this); cookie = new AxHost.ConnectionPointCookie( this.ActiveXInstance, helper, typeof(DWebBrowserEvents2)); } [PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")] protected override void DetachSink() { // Disconnect the client that handles the event // from the underlying ActiveX control. if (cookie != null) { cookie.Disconnect(); cookie = null; } base.DetachSink(); }


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WebBrowser クラス
WebBrowser メンバ
System.Windows.Forms 名前空間
CreateSink
その他の技術情報
DWebBrowserEvents2 インターフェイス
- WebBrowser.DetachSink メソッドのページへのリンク