다음을 통해 공유


HTMLWindow3 인터페이스

업데이트: 2007년 11월

Visual Studio IDE(통합 개발 환경)에서 HTML 문서 창을 나타냅니다.

네임스페이스:  EnvDTE90
어셈블리:  EnvDTE90(EnvDTE90.dll)

구문

<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

설명

문서가 HTML 문서인 경우 Window 개체의 Object 속성에서 HTMLWindow3이 반환됩니다. CurrentTab 속성이 vsHTMLTabsSource로 설정된 경우에는 Window.Selection 및 Document.Selection에서 TextSelection 개체를 반환합니다.

Visual Studio 2008 HTML 편집기에 분할 뷰가 도입되어 HTMLWindow3, vsHTMLPanesvsHTMLViews가 추가되었습니다. 분할 뷰는 HTML 편집기 창의 탭 및 뷰 요소를 구분합니다. 뷰(디자인 또는 소스)를 전환하더라도 탭(디자인/분할/소스)이 반드시 전환되지는 않습니다. 예를 들어 분할 탭을 클릭하면 디자인 및 소스 뷰 간에 전환해도 탭이 변경되지 않습니다. 단지 분할 뷰에서 디자인 및 소스 부분이 활성화되거나 비활성화됩니다.

이제 Visual Studio 2008 HTMLWindow 개체에서도 현재 뷰(디자인 또는 소스)와 현재 창(디자인, 소스 또는 분할 탭)을 반환하는 HTMLWindow3 인터페이스를 구현합니다.

HTMLWindow3 규칙

HTMLWindow3 동작은 다음과 같습니다.

가져오기

현재 창(탭)

현재 뷰 반환

vsHTMLPaneDesign

vsHTMLViewDesign

vsHTMLPaneSource

vsHTMLViewSource

vsHTMLPaneSplit

활성화된 부분에 따라 vsHTMLViewDesign 또는 vsHTMLViewSource입니다.

Set

현재 창(탭)

설정 값

vsHTMLPaneDesign

  • 뷰를 vsHTMLViewSource로 설정하거나 창을 vsHTMLPaneSource로 설정하면 HTML 편집기가 소스 뷰와 소스 창으로 전환됩니다.

  • 창을 vsHTMLPaneSplit으로 설정하면 HTML 편집기가 디자인 부분이 활성화된 상태로 분할 창으로 전환됩니다.

vsHTMLPaneSource

  • 뷰를 vsHTMLViewDesign으로 설정하거나 창을 vsHTMLPaneDesign으로 설정하면 HTML 편집기가 디자인 뷰와 디자인 창으로 전환됩니다.

  • 창을 vsHTMLPaneSplit으로 설정하면 HTML 편집기가 소스 부분이 활성화된 상태로 분할 창으로 전환됩니다.

vsHTMLPaneSplit

  • 뷰를 vsHTMLViewDesign으로 설정하면 편집기가 분할 창의 디자인 부분으로 전환됩니다. 창이 디자인 뷰로 변경되지는 않습니다.

  • 뷰를 vsHTMLViewSource로 설정하면 편집기가 분할 창의 소스 부분으로 전환됩니다. 창이 소스 창으로 변경되지는 않습니다.

  • 창을 vsHTMLPaneDesign으로 설정하면 편집기가 디자인 뷰와 디자인 창으로 전환됩니다.

  • 창을 vsHTMLPaneSource로 설정하면 편집기가 소스 뷰와 소스 창으로 전환됩니다.

예제

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

참고 항목

참조

HTMLWindow3 멤버

EnvDTE90 네임스페이스