次の方法で共有


HTMLWindow3 Interface

Definition

Represents an HTML document window in the Visual Studio integrated development environment (IDE).

public interface class HTMLWindow3
public interface class HTMLWindow3
__interface HTMLWindow3
[System.Runtime.InteropServices.Guid("BAD0A3DD-8109-4684-B806-A5282267BFE4")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface HTMLWindow3
[System.Runtime.InteropServices.Guid("BAD0A3DD-8109-4684-B806-A5282267BFE4")]
public interface HTMLWindow3
[<System.Runtime.InteropServices.Guid("BAD0A3DD-8109-4684-B806-A5282267BFE4")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type HTMLWindow3 = interface
[<System.Runtime.InteropServices.Guid("BAD0A3DD-8109-4684-B806-A5282267BFE4")>]
type HTMLWindow3 = interface
Public Interface HTMLWindow3
Attributes

Examples

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.");  
}  

Remarks

HTMLWindow3 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 CurrentTab property is set to vsHTMLTabsSource.

HTMLWindow3, vsHTMLPanes and vsHTMLViews were added with the introduction of Split view in the Visual Studio 2008 HTML editor. Split view separates the tab and view elements of the HTML Editor window. Switching the view (to either Design or Source) does not necessarily mean switching the tab (Design/Split/Source). For example, when you click the Split tab, switching views between Design and Source does not change the tab, it only activates or deactivates the Design and Source parts in the Split view.

The Visual Studio 2008 HTMLWindow object now also implements the HTMLWindow3 interface that returns the current view (either Design or Source) and the current pane (tab, either Design, Source, or Split).

HTMLWindow3 Rules

The behavior of HTMLWindow3 is:

Get

Current Pane (Tab) Current View Returns
vsHTMLPaneDesign vsHTMLViewDesign
vsHTMLPaneSource vsHTMLViewSource
vsHTMLPaneSplit Either vsHTMLViewDesign or vsHTMLViewSource, depending on which part is active.

Set

Current Pane (Tab) Setting
vsHTMLPaneDesign - Setting the view to vsHTMLViewSource or the pane to vsHTMLPaneSource switches the HTML Editor to Source view and Source pane.
- Setting the pane to vsHTMLPaneSplit switches the HTML Editor to Split pane with the Design part active.
vsHTMLPaneSource - Setting the view to vsHTMLViewDesign or the pane to vsHTMLPaneDesign switches the HTML Editor to Design view and Design pane.
- Setting the pane to vsHTMLPaneSplit switches the HTML Editor to Split pane with the Source part active.
vsHTMLPaneSplit - Setting the view to vsHTMLViewDesign switches the editor to the Design part of the Split pane. The pane does NOT change to Design view.
- Setting the view to vsHTMLViewSource switches the editor to the Source part of the Split pane. The pane does not change to Source pane.
- Setting the pane to vsHTMLPaneDesign switches the editor to Design view and Design pane.
- Setting the pane to vsHTMLPaneSource switches the editor to Source view and Source pane.

Properties

CurrentPane

Gets or sets the current HTML Editor window type.

CurrentView

Gets or sets whether the HTML Editor window is in Source, Designer, or Split view.

Methods

WaitForBackgroundProcessingComplete(vsHTMLBackgroundTasks)

Pauses program execution until background processing completes.

Applies to