HTMLWindow3 (Interfaz)

Actualización: noviembre 2007

Representa una ventana de documento HTML en el entorno de desarrollo integrado (IDE) de Visual Studio.

Espacio de nombres:  EnvDTE90
Ensamblado:  EnvDTE90 (en EnvDTE90.dll)

Sintaxis

<GuidAttribute("BAD0A3DD-8109-4684-B806-A5282267BFE4")> _
Public Interface HTMLWindow3

Dim instance As HTMLWindow3
[GuidAttribute("BAD0A3DD-8109-4684-B806-A5282267BFE4")]
public interface HTMLWindow3
[GuidAttribute(L"BAD0A3DD-8109-4684-B806-A5282267BFE4")]
public interface class HTMLWindow3
public interface HTMLWindow3

Comentarios

La propiedad Object del objeto Window devuelve HTMLWindow3 cuando el documento es un documento HTML. Window.Selection y Document.Selection devuelven un objeto TextSelection cuando la propiedad CurrentTab se establece en vsHTMLTabsSource.

HTMLWindow3, vsHTMLPanes y vsHTMLViews se agregaron con la introducción de la Vista dividida del editor HTML de Visual Studio 2008. La vista dividida separa los elementos de ficha y vista de la ventana del editor HTML. Cambiar de vista (Diseño o Código fuente) no implica necesariamente cambiar de ficha (Diseño, Dividir o Código fuente). Por ejemplo, al hacer clic en la ficha Dividir, cuando se alterna entre las vistas Diseño y Código fuente, la ficha no cambia, sino que simplemente se activan o desactivan las partes Diseño y Código fuente de la Vista dividida.

El objeto HTMLWindow de Visual Studio 2008 ahora también implementa la interfaz HTMLWindow3 que devuelve la vista actual (Diseño o Código fuente) y el panel actual (ficha Diseño, Código fuente o Dividir).

Reglas de HTMLWindow3

El comportamiento de HTMLWindow3 es:

Get

Panel actual (Ficha)

Devoluciones en la vista actual

vsHTMLPaneDesign

vsHTMLViewDesign

vsHTMLPaneSource

vsHTMLViewSource

vsHTMLPaneSplit

vsHTMLViewDesign o vsHTMLViewSource, dependiendo de qué parte esté activa.

Set

Panel actual (Ficha)

Valor

vsHTMLPaneDesign

  • Establecer la vista en vsHTMLViewSource o el panel en vsHTMLPaneSource cambia el editor HTML a la vista Código fuente y panel Código fuente.

  • Establecer el panel en vsHTMLPaneSplit cambia el editor HTML al panel Dividir con la parte Diseño activa.

vsHTMLPaneSource

  • Establecer la vista en vsHTMLViewDesign o el panel en vsHTMLPaneDesign cambia el editor HTML a la vista Diseño y panel Diseño.

  • Establecer el panel en vsHTMLPaneSplit cambia el editor HTML al panel Dividir con la parte Código fuente activa.

vsHTMLPaneSplit

  • Establecer la vista en vsHTMLViewDesign cambia el editor a la parte Diseño del panel Dividir. El panel NO cambia a la vista Diseño.

  • Establecer la vista en vsHTMLViewSource cambia el editor a la parte Código fuente del panel Dividir. El panel no cambia al panel Código fuente.

  • Establecer el panel en vsHTMLPaneDesign cambia el editor a la vista Diseño y panel Diseño.

  • Establecer el panel en vsHTMLPaneSource cambia el editor a la vista Código fuente y panel Código fuente.

Ejemplos

Sub HTMLWindow3Example(ByVal dte As EnvDTE80.DTE2)
    ' Open an HTML document before running this sample.
    If TypeOf dte.ActiveDocument.ActiveWindow.Object Is HTMLWindow3 _
        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 HTMLWindow3 object and determine which tab is 
            ' currently active.
            Dim objHTMLWin As HTMLWindow3 = _
            CType(dte.ActiveDocument.ActiveWindow.Object, HTMLWindow3)
            Dim Tab As vsHTMLTabs = CType(objHTMLWin.CurrentTab, _
              vsHTMLTabs)
            Dim cpane As vsHTMLPanes = vsHTMLPanes.vsHTMLPaneSplit

            ' Switch to the "split" view, source view.
            objHTMLWin.CurrentPane = vsHTMLPanes.vsHTMLPaneSplit
            objHTMLWin.CurrentView = vsHTMLViews.vsHTMLViewSource

            ' Get an EditPoint at the start of the text.
            Dim objTextWin As TextWindow = _
              CType(objHTMLWin.CurrentTabObject, TextWindow)
            Dim objEP As EditPoint = _
            objTextWin.ActivePane.StartPoint.CreateEditPoint

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

            ' Switch back to the original view of the HTML file.
            'objHTMLWin.CurrentTab = Tab
        Else
            MsgBox("You must open an HTML document.")
        End If
    End Sub
public void HTMLWindowExample(_DTE dte)
{
    // Open an HTML document before running this sample.
    if (dte.ActiveDocument.ActiveWindow.Object is HTMLWindow3)
    {
        HTMLWindow3 objHTMLWin;
        vsHTMLTabs Tab;
        String strFileName;
        // Ask the user for a file to insert into the body of the HTML 
        // document. This file should be an HTML fragment.
        strFileName = Microsoft.VisualBasic.Interaction.InputBox 
        ("Enter the name of a file to insert at the end of the HTML 
        document:","","",100,100);
        // Get the HTMLWindow3 object and determine which tab is 
        // currently active.
        objHTMLWin = dte.ActiveDocument.ActiveWindow.Object as 
        HTMLWindow3;
        Tab = objHTMLWin.CurrentTab;

        // Switch to the "source" tab.
        objHTMLWin.CurrentPane = vsHTMLPanes.vsHTMLPaneSplit;
        objHTMLWin.CurrentTab = vsHTMLViews.vsHTMLViewSource;

        // Get an EditPoint at the start of the text.
        TextWindow objTextWin;
        EditPoint ep;
        EditPoint ep2 = null;
        TextRanges textRanges = null;
        objTextWin = objHTMLWin.CurrentTabObject as TextWindow;
        ep = objTextWin.ActivePane.StartPoint.CreateEditPoint();
        textRanges = objTextWin.Selection.TextRanges;

        // Look for the end of the document body.
        if (ep.FindPattern 
        ("</body>",(int)vsFindOptions.vsFindOptionsNone, ref ep2, ref 
        textRanges))
            // Insert the contents of the file.
            ep.InsertFromFile (strFileName);
            // Switch back to the original view of the HTML file.
            objHTMLWin.CurrentTab = Tab;
    }
    else
        MessageBox.Show ("You must open an HTML document.");
}

Vea también

Referencia

HTMLWindow3 (Miembros)

EnvDTE90 (Espacio de nombres)