WebBrowser.DetachSink 메서드

정의

CreateSink() 메서드의 연결된 이벤트 처리 클라이언트를 내부 ActiveX 컨트롤에서 해제합니다.

protected:
 override void DetachSink();
protected override void DetachSink ();
override this.DetachSink : unit -> unit
Protected Overrides Sub DetachSink ()

예제

다음 코드 예제에서는 OLE DWebBrowserEvents2 인터페이스의 이벤트로 표준 WebBrowser 이벤트를 보완하는 클래스에서 WebBrowser 이 메서드를 NavigateError 사용하는 방법을 보여 줍니다.

전체 코드 예제를 보려면 CreateSink합니다.

AxHost.ConnectionPointCookie cookie;
WebBrowser2EventHelper helper;

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

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

설명

이 메서드는 관리 WebBrowser 되지 않는 ActiveX 컨트롤을 사용하여 OLE 개발에 익숙하고 ActiveX 컨트롤의 관리 래퍼인 Windows Forms WebBrowser 컨트롤의 기능을 확장하려는 경우에 유용합니다. 이 확장성을 사용하여 래퍼 컨트롤에서 제공하지 않는 ActiveX 컨트롤의 이벤트를 구현할 수 있습니다.

적용 대상

추가 정보