출력 창 (Visual Studio SDK)
해당 출력 창 집합을 작성 하 고 읽을 텍스트 틀입니다. Visual Studio이러한 기본 제공 창 정의: 빌드, 어떤 프로젝트를 빌드에 대 한 메시지 전달 및 일반를 통해 Visual Studio 통합된 개발 환경 (IDE)에 대 한 메시지를 전달 합니다. 프로젝트에 대 한 참조를 받을 빌드 창 자동으로의 IVsBuildableProjectCfg 인터페이스 메서드를 및 Visual Studio 행사에 직접 액세스할 수는 일반 창을 통해는 SVsGeneralOutputWindowPane 서비스. 기본 제공 창에 작성 하 고 사용자 고유의 사용자 지정 창 관리할 수 있습니다.
제어할 수 있습니다의 출력 창을 통해 직접는 IVsOutputWindow 및 IVsOutputWindowPane 인터페이스입니다. IVsOutputWindow 인터페이스를 통해 제공 되는 SVsOutputWindow 서비스를 만들고, 검색 하 고 파괴 하는 메서드를 정의 출력 창입니다. IVsOutputWindow 인터페이스 표시 창, 창, 숨기기 및 해당 텍스트 조작을 위한 메서드를 정의 합니다. 또 다른 방법에 대 한 제어는 출력 창입니다는 OutputWindow 및 OutputWindowPane Visual Studio 자동화 개체 모델에. 이러한 개체는 거의 모든 기능을 캡슐화는 IVsOutputWindow 및 IVsOutputWindowPane 인터페이스입니다. 또한는 OutputWindow 및 OutputWindowPane 개체를 쉽게 열거할 수 있도록 몇 가지 높은 수준의 기능 추가 출력 창 창에서 텍스트를 검색 하 고.
예제
설명
새로 만드는 방법을 보여 주는이 예제 출력 를 사용 하 여 창 있는 IVsOutputWindow 인터페이스.
코드
Private Function CreatePane(ByVal paneGuid As Guid, ByVal title As String, ByVal visible As Boolean, ByVal clearWithSolution As Boolean) As IVsOutputWindowPane
Dim output As IVsOutputWindow = DirectCast(GetService(GetType(SVsOutputWindow)), IVsOutputWindow)
Dim pane As IVsOutputWindowPane
' Create a new pane.
output.CreatePane(paneGuid, title, Convert.ToInt32(visible), Convert.ToInt32(clearWithSolution))
' Retrieve the new pane.
output.GetPane(paneGuid, pane)
Return pane
End Function
IVsOutputWindowPane CreatePane(Guid paneGuid, string title,
bool visible, bool clearWithSolution)
{
IVsOutputWindow output =
(IVsOutputWindow)GetService(typeof(SVsOutputWindow));
IVsOutputWindowPane pane;
// Create a new pane.
output.CreatePane(
ref paneGuid,
title,
Convert.ToInt32(visible),
Convert.ToInt32(clearWithSolution));
// Retrieve the new pane.
output.GetPane(ref paneGuid, out pane);
return pane;
}
예제
설명
작성 하는 방법을 보여 주는이 예제는 출력 창을 사용 하 여는 OutputWindow 개체입니다.
코드
Private Function CreatePane(ByVal title As String) As OutputWindowPane
Dim dte As DTE2 = DirectCast(GetService(GetType(DTE)), DTE2)
Dim panes As OutputWindowPanes = dte.ToolWindows.OutputWindow.OutputWindowPanes
Try
' If the pane exists already, return it.
Return panes.Item(title)
Catch generatedExceptionName As ArgumentException
' Create a new pane.
Return panes.Add(title)
End Try
End Function
OutputWindowPane CreatePane(string title)
{
DTE2 dte = (DTE2)GetService(typeof(DTE));
OutputWindowPanes panes =
dte.ToolWindows.OutputWindow.OutputWindowPanes;
try
{
// If the pane exists already, return it.
return panes.Item(title);
}
catch (ArgumentException)
{
// Create a new pane.
return panes.Add(title);
}
}
설명
하지만 OutputWindowPanes 컬렉션을 사용 하면 검색에 출력 창 제목으로 창 제목입니다 보장 고유 해야 합니다. 제목 고유 하 게 확실치 않은 경우 사용 하는 GetPane 올바른 창에서 GUID 검색 하는 방법.
예제
설명
삭제 하는 방법을 보여 주는이 예제는 출력 창입니다.
코드
Private Sub DeletePane(ByVal paneGuid As Guid)
Dim output As IVsOutputWindow = DirectCast(GetService(GetType(SVsOutputWindow)), IVsOutputWindow)
output.DeletePane(paneGuid)
End Sub
void DeletePane(Guid paneGuid)
{
IVsOutputWindow output =
(IVsOutputWindow)GetService(typeof(SVsOutputWindow));
output.DeletePane(ref paneGuid);
}
예제
설명
삭제 하는 방법을 보여 주는이 예제는 출력 지정 창에 OutputWindowPane 개체입니다.
코드
Private Sub DeletePane(ByVal pane As OutputWindowPane)
Dim output As IVsOutputWindow = DirectCast(GetService(GetType(SVsOutputWindow)), IVsOutputWindow)
Dim paneGuid As New Guid(pane.Guid)
output.DeletePane(paneGuid)
End Sub
void DeletePane(OutputWindowPane pane)
{
IVsOutputWindow output =
(IVsOutputWindow)GetService(typeof(SVsOutputWindow));
Guid paneGuid = new Guid(pane.Guid);
output.DeletePane(ref paneGuid);
}
예제
설명
기본 제공 검색 하는 방법을 보여 주는이 예제 일반 의 창에 출력 창입니다.
코드
Private Function GetGeneralPane() As IVsOutputWindowPane
Return DirectCast(GetService(GetType(SVsGeneralOutputWindowPane)), IVsOutputWindowPane)
End Function
IVsOutputWindowPane GetGeneralPane()
{
return (IVsOutputWindowPane)GetService(
typeof(SVsGeneralOutputWindowPane));
}
예제
설명
오류에 대 한 표준 빌드 메시지를 구문 분석 하 고 항목을 추가 하는 방법을 보여 주는이 예제는 오류 창에서 적절 한 경우 메시지를 보내기 전에 출력 창입니다.
코드
Private Sub OutputTaskItemStringExExample(ByVal buildMessage As String, ByVal buildPane As IVsOutputWindowPane, ByVal launchPad As IVsLaunchPad)
Dim priority As UInteger() = New UInteger(0) {}, lineNumber As UInteger() = New UInteger(0) {}
Dim fileName As String() = New String(0) {}, taskItemText As String() = New String(0) {}
Dim taskItemFound As Integer() = New Integer(0) {}
' Determine whether buildMessage contains an error.
launchPad.ParseOutputStringForTaskItem(buildMessage, priority, fileName, lineNumber, taskItemText, taskItemFound)
' If buildMessage contains an error, send it to both the
' Error window and the Output window; otherwise, send it
' to the Output window only.
If taskItemFound(0) <> 0 Then
buildPane.OutputTaskItemStringEx(buildMessage, DirectCast(priority(0), VSTASKPRIORITY), VSTASKCATEGORY.CAT_BUILDCOMPILE, Nothing, 0, fileName(0), _
lineNumber(0), taskItemText(0), Nothing)
Else
buildPane.OutputString(buildMessage)
End If
buildPane.OutputString(vbLf)
End Sub
void OutputTaskItemStringExExample(string buildMessage,
IVsOutputWindowPane buildPane, IVsLaunchPad launchPad)
{
uint[] priority = new uint[1], lineNumber = new uint[1];
string[] fileName = new string[1], taskItemText = new string[1];
int[] taskItemFound = new int[1];
// Determine whether buildMessage contains an error.
launchPad.ParseOutputStringForTaskItem(
buildMessage,
priority,
fileName,
lineNumber,
taskItemText,
taskItemFound);
// If buildMessage contains an error, send it to both the
// Error window and the Output window; otherwise, send it
// to the Output window only.
if (taskItemFound[0] != 0)
{
buildPane.OutputTaskItemStringEx(
buildMessage,
(VSTASKPRIORITY)priority[0],
VSTASKCATEGORY.CAT_BUILDCOMPILE,
null,
0,
fileName[0],
lineNumber[0],
taskItemText[0],
null);
}
else
{
buildPane.OutputString(buildMessage);
}
buildPane.OutputString("\n");
}