다음을 통해 공유


방법: 창 특성 변경

Visual Studio의 창은 자동화 모델에서 Window2 개체로 표현됩니다.해당 멤버를 사용하여 너비, 높이, 표시 여부 등의 창 특성을 조작할 수 있습니다.Window2 컬렉션을 사용하면 서로 도킹된 두 개 이상의 도구 창으로 구성된 연결된 창을 만들 수 있습니다.또한 해당 멤버를 사용하여 프레임으로 추가 창을 도킹하거나 프레임에서 추가 창을 도킹 해제할 수 있습니다.

[!참고]

연결할 창은 표시된 상태여야 합니다.숨겨진 창이 있으면 예외가 발생합니다.Visible 속성을 사용하여 창을 표시할 수 있습니다.

Windows2 컬렉션을 사용하면 도구 창을 직접 만들 수도 있습니다.자세한 내용은 방법: 도구 창 만들기 및 제어를 참조하십시오.

[!참고]

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

예제

다음 예제에서는 자동화 모델의 다양한 멤버를 참조 및 사용하여 도구 창을 조작하는 방법을 보여 줍니다.이 예제에서는 연결된 도구 창을 만들고 두 개의 Visual Studio 도구 창인 솔루션 탐색기출력 창을 함께 연결합니다.또한 도구 창의 크기를 조정하고 도킹 해제하는 방법도 보여 줍니다.이 코드를 실행하기 전에 EnvDTE 어셈블리 참조의 "Interop 형식 포함" 속성이 False로 설정되어 있는지 확인합니다. 추가 기능에서 샘플 코드를 실행하는 방법에 대한 자세한 내용은 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

주의 정보주의

이 예제를 실행하면 현재 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)
    chgWindow(_applicationObject)
End Sub

Public Sub chgWindow(ByVal dte As DTE2)
    ' Create variables for the various tool windows.
    Dim winFrame As EnvDTE80.Window2
    Dim win1 As Window = _
      dte.Windows.Item(Constants.vsWindowKindSolutionExplorer)
    Dim win2 As Window = dte.Windows. _
    Item(Constants.vsWindowKindOutput)
    Dim win3 As Window = dte.Windows. _
    Item(Constants.vsWindowKindCommandWindow)

    ' Create a linked window frame and dock Solution 
    ' Explorer and the Ouput window together inside it.
    winFrame = CType(dte.Windows.CreateLinkedWindowFrame(win1, win2, _
      vsLinkedWindowType.vsLinkedWindowTypeDocked), Window2)
    MsgBox("Total number of windows in the linked window frame: " & _
    winFrame.LinkedWindows.Count)

    ' Add another tool window, the Command window, to the frame 
    ' with the other two.
    winFrame.LinkedWindows.Add(win3)
    MsgBox("Total number of windows in the linked window frame: " & _
    winFrame.LinkedWindows.Count)

    ' Resize the entire linked window frame.
    winFrame.Width = 500
    winFrame.Height = 600
    MsgBox("Frame height and width changed. Now changing Command _
      window height.")

    ' Resize the height of the Command window.
    winFrame.LinkedWindows.Item(3).Height = 800
    MsgBox("Now undocking the Command window from the frame.")

    ' Undock the Command window from the frame.
    winFrame.LinkedWindows.Remove(win3)
End Sub
public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    chgWindow(_applicationObject);
}

public void chgWindow(DTE2 dte)
{
    // Create variables for the various tool windows.
    EnvDTE80.Window2 winFrame;
    Window win1 = 
      dte.Windows.Item(Constants.vsWindowKindSolutionExplorer);
    Window win2 = dte.Windows.Item(Constants.vsWindowKindOutput);
    Window win3 = 
      dte.Windows.Item(Constants.vsWindowKindCommandWindow);

    // Create a linked window frame and dock Solution 
    // Explorer and the Ouput window together inside it.
    winFrame = (Window2)dte.Windows.CreateLinkedWindowFrame(win1, win2, 
      vsLinkedWindowType.vsLinkedWindowTypeDocked);
    System.Windows.Forms.MessageBox.Show("Total number of windows in 
      the linked window frame: " + winFrame.LinkedWindows.Count);

    // Add another tool window, the Command window, to the frame 
    // with the other two.
    winFrame.LinkedWindows.Add(win3);
    System.Windows.Forms.MessageBox.Show(
      "Total number of windows in the linked window frame: " + 
      winFrame.LinkedWindows.Count);

    // Resize the entire linked window frame.
    winFrame.Width = 500;
    winFrame.Height = 600;
    System.Windows.Forms.MessageBox.Show(
      "Frame height and width changed." +
      "Now changing Command window height.");

    // Resize the height of the Command window.
    winFrame.LinkedWindows.Item(3).Height = 800;
    System.Windows.Forms.MessageBox.Show(
      "Now undocking the Command window from the frame.");

    // Undock the Command window from the frame.
    winFrame.LinkedWindows.Remove(win3);
}

참고 항목

작업

방법: 도구 창 만들기 및 제어

방법: 추가 기능 만들기

연습: 마법사 만들기

개념

자동화 개체 모델 차트

기타 리소스

환경 창 만들기 및 제어

추가 기능 및 마법사 만들기

자동화 및 확장성 참조