HtmlElementEventHandler 대리자

정의

HtmlDocument, HtmlElementHtmlWindow의 관련 이벤트와 Click, MouseDown을 처리할 메서드를 나타냅니다.

public delegate void HtmlElementEventHandler(System::Object ^ sender, HtmlElementEventArgs ^ e);
public delegate void HtmlElementEventHandler(object sender, HtmlElementEventArgs e);
public delegate void HtmlElementEventHandler(object? sender, HtmlElementEventArgs e);
type HtmlElementEventHandler = delegate of obj * HtmlElementEventArgs -> unit
Public Delegate Sub HtmlElementEventHandler(sender As Object, e As HtmlElementEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
HtmlElementEventArgs

이벤트 데이터가 포함된 HtmlElementEventArgs입니다.

예제

다음 코드에 대 한 이벤트 처리기를 연결 합니다 MouseDown, MouseMove, 및 MouseUp 이벤트를 HtmlDocument입니다. 이 코드 샘플 프로젝트의 인스턴스가 있는 것으로 가정 합니다 WebBrowser 제어 라는 WebBrowser1합니다.

private:
   void webBrowser1_DocumentCompleted( Object^ /*sender*/, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^ /*e*/ )
   {
      WebBrowser1->Document->MouseDown += gcnew HtmlElementEventHandler( this, &Form1::Document_MouseDown );
      WebBrowser1->Document->MouseMove += gcnew HtmlElementEventHandler( this, &Form1::Document_MouseMove );
      WebBrowser1->Document->MouseUp += gcnew HtmlElementEventHandler( this, &Form1::Document_MouseUp );
   }

   void Document_MouseDown( Object^ /*sender*/, HtmlElementEventArgs^ /*e*/ )
   {
      // Insert your code here.
   }

   void Document_MouseMove( Object^ /*sender*/, HtmlElementEventArgs^ /*e*/ )
   {
      // Insert your code here.
   }

   void Document_MouseUp( Object^ /*sender*/, HtmlElementEventArgs^ /*e*/ )
   {
      // Insert your code here.
   }
private void webBrowser1_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
    WebBrowser1.Document.MouseDown += new HtmlElementEventHandler(Document_MouseDown);
    WebBrowser1.Document.MouseMove += new HtmlElementEventHandler(Document_MouseMove);
    WebBrowser1.Document.MouseUp += new HtmlElementEventHandler(Document_MouseUp);
}

private void Document_MouseDown(object sender, HtmlElementEventArgs e)
{
    // Insert your code here.
}

private void Document_MouseMove(object sender, HtmlElementEventArgs e)
{
    // Insert your code here.
}

private void Document_MouseUp(object sender, HtmlElementEventArgs e)
{
    // Insert your code here.
}
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    Dim Doc As HtmlDocument = WebBrowser1.Document

    AddHandler Doc.MouseDown, New HtmlElementEventHandler(AddressOf Document_MouseDown)
    AddHandler Doc.MouseMove, New HtmlElementEventHandler(AddressOf Document_MouseMove)
    AddHandler Doc.MouseUp, New HtmlElementEventHandler(AddressOf Document_MouseUp)
End Sub

Private Sub Document_MouseDown(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
    ' Insert your code here.
End Sub

Private Sub Document_MouseMove(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
    ' Insert your code here.
End Sub

Private Sub Document_MouseUp(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
    ' Insert your code here.
End Sub

설명

HtmlElementEventHandler 대리자를 만들 때, 이벤트를 처리할 메서드를 식별합니다. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

HTML 문서에서 문서에 이벤트 처리기를 연결 하기 위해 로드를 완료할 때까지 기다려야 합니다. 로드 완료 되기 전에 처리기를 연결 하려는 경우 연결 작업이 실패할 수 있습니다. 새 문서에 대 한 이벤트 처리기를 연결 하는 것이 좋습니다에는 DocumentCompleted 에 대 한 이벤트 처리기는 WebBrowser 제어 합니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상