방법: 출력 창 제어

업데이트: 2007년 11월

출력 창에서는 IDE(통합 개발 환경)의 다양한 기능에 대한 상태 메시지를 표시합니다. 이러한 메시지에는 프로젝트를 컴파일할 때 발생하는 빌드 오류 메시지와 대상 데이터베이스에 대해 저장 프로시저의 T-SQL 구문을 검사할 때 발생하는 결과 메시지 등이 있습니다. 명령 창에서 호출되는 명령 또는 외부 도구 기능 같은 특정 IDE 기능에서는 출력을 전용 출력 창으로 전달합니다. .bat 또는 .com 파일과 같이 일반적으로 Windows 명령 창에 표시되는 외부 도구의 출력도 이 출력 창에 표시할 수 있습니다.

Visual Studio 자동화 모델에서는 출력 창을 제어하기 위한 다음과 같은 개체를 제공합니다.

개체 이름

설명

OutputWindow

출력 창을 나타냅니다.

OutputWindowPanes

모든 출력 창을 포함하는 컬렉션입니다.

OutputWindowPane

출력 창의 단일 창을 나타냅니다.

OutputWindowEvents

출력 창에서 발생하는 이벤트에 응답합니다.

출력 창의 내용뿐 아니라 너비 및 높이와 같은 특성도 제어할 수 있습니다. 자세한 내용은 방법: 창 특성 변경을 참조하십시오.

출력 창에 표시되는 텍스트는 코드 편집기의 코드와 마찬가지로 TextDocument 개체, EditPoint 개체 및 이와 유사한 개체를 사용하여 Visual Studio 편집기 자동화 모델로 조작할 수 있습니다. 자세한 내용은 방법: 코드 편집기 제어(Visual Basic)를 참조하십시오.

참고:

표시되는 대화 상자와 메뉴 명령은 실제 설정이나 버전에 따라 도움말에서 설명하는 것과 다를 수 있습니다. 이러한 절차는 일반 개발 설정을 사용하여 개발되었습니다. 설정을 변경하려면 도구 메뉴에서 설정 가져오기 및 내보내기를 선택합니다. 자세한 내용은 Visual Studio 설정을 참조하십시오.

예제

이 예제에서는 출력 창에 새 창을 추가하는 방법과 추가한 창에 텍스트를 추가하는 방법을 보여 줍니다. 예제를 실행하는 방법에 대한 자세한 내용은 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

Public Sub OnConnection(ByVal application As Object, ByVal _
  connectMode As ext_ConnectMode, ByVal addInInst As Object, _
  ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    ' Pass the applicationObject member variable to the code example.
    OutputWindowTest(_applicationObject)
End Sub

Sub OutputWindowTest(ByVal dte As DTE2)
    ' Create a tool window reference for the Output window
    ' and window pane.
    Dim ow As OutputWindow = dte.ToolWindows.OutputWindow
    Dim owP As OutputWindowPane

    ' Add a new pane to the Output window.
    owP = ow.OutputWindowPanes.Add("A New Pane")
    ' Add a line of text to the new pane.
    owP.OutputString("Some Text")
End Sub
public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    OutputWindowTest(_applicationObject);
}

public void OutputWindowTest(DTE2 dte)
{
    // Create a tool window reference for the Output window
    // and window pane.
    OutputWindow ow = dte.ToolWindows.OutputWindow;
    OutputWindowPane owP;

    // Add a new pane to the Output window.
    owP = ow.OutputWindowPanes.Add("A New Pane");
    // Add a line of text to the new pane.
    owP.OutputString("Some Text");
}

이 예제에서는 출력 창의 빌드 창에 텍스트를 추가한 다음 이를 검색합니다.

Public Sub OnConnection(ByVal application As Object, ByVal _
  connectMode As ext_ConnectMode, ByVal addInInst As Object, _
  ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    ' Pass the applicationObject member variable to the code example.
    writeReadOW(_applicationObject)
End Sub

Sub writeReadOW(ByVal dte As DTE2)
    ' Add-in code.
    ' Create a reference to the Output window.
    ' Create a tool window reference for the Output window
    ' and window pane.
    Dim ow As OutputWindow = dte.ToolWindows.OutputWindow
    Dim owP As OutputWindowPane
    ' Create a reference to the pane contents.
    Dim owPTxtDoc As TextDocument

    ' Select the Build pane in the Output window.
    owP = ow.OutputWindowPanes.Item("Build")
    owP.Activate()
    owPTxtDoc = owP.TextDocument

    ' Put some text in the pane.
    owP.OutputString("Testing 123.")
    ' Retrieve the text contents of the pane.
    MsgBox("Startpoint: " & owPTxtDoc.StartPoint.DisplayColumn)
    MsgBox(owPTxtDoc.StartPoint.CreateEditPoint. _
      GetText(owPTxtDoc.EndPoint))
End Sub
using System.Windows.Forms;
public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    writeReadOW(_applicationObject);
}

public void writeReadOW(DTE2 dte)
{
    // Add-in code.
    // Create a reference to the Output window.
    // Create a tool window reference for the Output window
    // and window pane.
    OutputWindow ow = dte.ToolWindows.OutputWindow;
    OutputWindowPane owP;
    // Create a reference to the pane contents.
    TextDocument owPTxtDoc;
    EditPoint2 strtPt;

    // Select the Build pane in the Output window.
    owP = ow.OutputWindowPanes.Item("Build");
    owP.Activate();
    owPTxtDoc = owP.TextDocument;
            
    // Put some text in the pane.
    owP.OutputString("Testing 123.");
    // Retrieve the text contents of the pane.
    System.Windows.Forms.MessageBox.Show("Startpoint: " + 
      owPTxtDoc.StartPoint.DisplayColumn);
    strtPt = (EditPoint2)owPTxtDoc.StartPoint.CreateEditPoint();
    System.Windows.Forms.MessageBox.Show
      (strtPt.GetText(owPTxtDoc.EndPoint));
}

참고 항목

작업

방법: 창 특성 변경

방법: 추가 기능 만들기

연습: 마법사 만들기

개념

자동화 개체 모델 차트

기타 리소스

환경 창 만들기 및 제어

추가 기능 및 마법사 만들기

자동화 및 확장성 참조