HtmlElement.DomElement Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recebe um ponteiro de interface não gerido para este elemento.
public:
property System::Object ^ DomElement { System::Object ^ get(); };
public object DomElement { get; }
member this.DomElement : obj
Public ReadOnly Property DomElement As Object
Valor de Propriedade
O ponteiro COM IUnknown para o elemento, que pode castar para uma das interfaces HTML dos elementos, como IHTMLElement.
Exemplos
O exemplo de código seguinte utiliza interfaces não geridas para pegar no texto atualmente selecionado e convertê-lo numa hiperligação, com o URL escolhido pelo utilizador. Este código foi escrito sob a suposição de que o seu formulário tem um WebBrowser controlo chamado WebBrowser1, e que adicionou a biblioteca MSHTML não gerida como referência ao seu projeto.
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
Observações
HtmlElement é um wrapper para o Internet Explorer Document Object Model (DOM), que é escrito usando o Component Object Model (COM). Se precisar de aceder a propriedades ou métodos não expostos nas interfaces COM subjacentes, como IHTMLElement, pode usar este objeto para os procurar.
Para usar as interfaces não geridas, terá de importar a biblioteca MSHTML (mshtml.dll) para a sua aplicação. No entanto, também pode executar propriedades e métodos não expostos usando o Invoke método.