HtmlElement.DomElement 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 요소에 대한 관리되지 않는 인터페이스 포인터를 가져옵니다.
public:
property System::Object ^ DomElement { System::Object ^ get(); };
public object DomElement { get; }
member this.DomElement : obj
Public ReadOnly Property DomElement As Object
속성 값
요소에 대한 COM IUnknown 포인터로, HTML 요소 인터페이스 중 하나로 캐스팅할 수 있습니다(예: IHTMLElement.).
예제
다음 코드 예제에서는 관리되지 않는 인터페이스를 사용하여 현재 선택한 텍스트를 가져와서 사용자가 선택한 URL을 사용하여 하이퍼링크로 변환합니다. 이 코드는 양식 WebBrowser 에 명명 WebBrowser1된 컨트롤이 있고 관리되지 않는 MSHTML 라이브러리를 프로젝트에 대한 참조로 추가했다는 가정 하에 작성되었습니다.
private void CreateHyperlinkFromSelection()
{
if (webBrowser1.Document != null)
{
MSHTML.IHTMLDocument2 iDoc = (MSHTML.IHTMLDocument2)webBrowser1.Document.DomDocument;
if (iDoc != null)
{
MSHTML.IHTMLSelectionObject iSelect = iDoc.selection;
if (iSelect == null)
{
MessageBox.Show("Please select some text before using this command.");
return;
}
MSHTML.IHTMLTxtRange txtRange = (MSHTML.IHTMLTxtRange)iSelect.createRange();
// Create the link.
if (txtRange.queryCommandEnabled("CreateLink"))
{
Object o = null;
txtRange.execCommand("CreateLink", true, o);
}
}
}
}
Private Sub CreateHyperlinkFromSelection()
If (WebBrowser1.Document IsNot Nothing) Then
Dim IDoc = WebBrowser1.Document.DomDocument
If (Not (IDoc Is Nothing)) Then
Dim ISelect = IDoc.selection
If (ISelect Is Nothing) Then
MsgBox("Please select some text before using this command.")
Exit Sub
End If
Dim TxtRange = ISelect.createRange()
' Create the link.
If (TxtRange.queryCommandEnabled("CreateLink")) Then
TxtRange.execCommand("CreateLink", True)
End If
End If
End If
End Sub
설명
HtmlElement COM(구성 요소 개체 모델)을 사용하여 작성된 Internet Explorer DOM(문서 개체 모델)의 래퍼입니다. 다음과 같이 IHTMLElement기본 COM 인터페이스에서 노출되지 않은 속성 또는 메서드에 액세스해야 하는 경우 이 개체를 사용하여 쿼리할 수 있습니다.
관리되지 않는 인터페이스를 사용하려면 MSHTML 라이브러리(mshtml.dll)를 애플리케이션으로 가져와야 합니다. 그러나 메서드를 사용하여 노출되지 않은 속성 및 메서드를 Invoke 실행할 수도 있습니다.