Export (0) Print
Expand All

HTMLWindow Interface

Represents an HTML document window.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

<GuidAttribute("F6576203-FBCE-477E-A66B-EDA237BB68A7")> _
Public Interface HTMLWindow

The HTMLWindow type exposes the following members.

Public propertyCurrentTabGets or sets the state (active or inactive) of the Source or the Designer tab in the HTML edit window.
Public propertyCurrentTabObjectGets the state (active or inactive) of the Source or the Designer tab in the HTML edit window.
Public propertyDTEGets the top-level extensibility object.
Public propertyParentGets the immediate parent object of a HTMLWindow object.

HTMLWindow is returned by the Object property of the Window object when the document is an HTML document. Window.Selection and Document.Selection returns a TextSelection object when the HTMLWindow.CurrentTab property is set to vsHTMLTabsSource.

Sub HTMLWindowExample(ByVal dte As EnvDTE.DTE)
    ' Open an HTML document before running this sample.
    If TypeOf dte.ActiveDocument.ActiveWindow.Object Is HTMLWindow Then
        ' Ask the user for a file to insert into the body of the HTML 
        ' document. This file should be an HTML fragment.
        Dim strFile As String = InputBox("Enter the name of a file to _
        insert at the end of the HTML document:")
        ' Get the HTMLWindow object and determine which tab is 
        ' currently active.
        Dim objHTMLWin As HTMLWindow = _
        Dim Tab As vsHTMLTabs = objHTMLWin.CurrentTab

        ' Switch to the "source" tab.
        objHTMLWin.CurrentTab = vsHTMLTabs.vsHTMLTabsSource

        ' Get an EditPoint at the start of the text.
        Dim objTextWin As TextWindow = objHTMLWin.CurrentTabObject
        Dim objEP As EditPoint = _

        ' Look for the end of the document body.
        If objEP.FindPattern("</body>") Then
            ' Insert the contents of the file.
        End If

        ' Switch back to the original view of the HTML file.
        objHTMLWin.CurrentTab = Tab
        MsgBox("You must open an HTML document.")
    End If
End Sub
© 2015 Microsoft