Share via


방법: 동적 도움말 창 제어

업데이트: 2007년 11월

Visual Studio에는 사용자의 컨텍스트를 기반으로 관련 도움말 항목에 대한 링크를 제공하는 동적 도움말 창이 있습니다. 예를 들어, 코드 편집기에서 편집을 시작하면 코드 편집기를 사용하는 방법에 대한 항목이 동적 도움말 창에 표시됩니다. 이는 현재 컨텍스트에 관련된 키워드를 도움말 항목에 관련된 키워드 목록과 비교한 결과입니다.

ContextAttributes 컬렉션과 ContextAttribute 개체를 사용하면 Visual Studio의 특정 창에 적용되는 키워드 컬렉션을 나열할 수 있고, 특성을 추가하거나 우선 순위를 설정할 수도 있습니다. 이를 통해 자동화 클라이언트에서는 해당 창 또는 탭이나 링크와 같은 창 요소가 선택될 때 동적 도움말 창에 선택 항목을 표시할 수 있습니다.

ContextAttribute 개체는 특정 창이나 창 요소에 대한 컨텍스트를 나타내지만 ContextAttributes는 지정된 창의 모든 ContextAttribute 개체 컬렉션입니다. 컨텍스트는 Filter, Lookup 및 LookupF1의 세 가지 컨텍스트 형식으로 구성됩니다.

Filter

컨텍스트 컬렉션에 특성이 추가됩니다. 특성은 동적 도움말 창에 표시되는 F1 및 조회 키워드 항목을 필터링하거나 사용자가 F1 키를 누를 때 표시되는 항목을 필터링하는 데 사용되는 이름/값 쌍입니다.

Lookup

컨텍스트 컬렉션에 키워드가 추가됩니다. 이 키워드에 해당하는 항목이 동적 도움말 창에 표시됩니다. 조회 키워드는 동적 도움말 창에 표시되는 백그라운드 항목 또는 관련 항목의 목록을 제공합니다. 동적 도움말 창의 키워드 항목 목록은 사용자가 현재 선택 영역을 변경할 때 업데이트됩니다. 조회 키워드는 컴파일된 도움말 파일의 인덱스에 표시되는 키워드와 동일한 소스에서 파생됩니다.

LookupF1

이 키워드에 해당하는 항목은 동적 도움말 창에 표시되며 F1 도움말 항목을 찾는 데 사용됩니다. F1 키워드는 도구 창, 편집기 또는 모달 대화 상자와 같은 컨텍스트 요소를 선택한 상태에서 F1을 누를 때 도움말 항목을 제공합니다. F1 키워드 항목은 동적 도움말 창에도 나타납니다. F1 키워드는 컨텍스트 컬렉션에 추가됩니다.

다음의 세 가지 컨텍스트 특성 형식은 ContextAttributes 개체가 시작된 위치를 나타냅니다.

Global

전역 IDE(통합 개발 환경) 컨텍스트입니다.

High Priority

High Priority 컨텍스트 컬렉션입니다. High Priority 컨텍스트 특성은 항목 링크가 동적 도움말 창에서 해당 링크 그룹의 맨 위에 표시됨을 의미합니다.

Window

창 컨텍스트입니다.

ContextAttributes 컬렉션은 다음 개체에서 사용할 수 있습니다.

ContextAttributes

항목을 정렬할 때 우선 순위가 가장 낮은 전역 컨텍스트 컬렉션에 영향을 줍니다.

ContextAttributes

창의 컨텍스트 컬렉션에 영향을 줍니다. 도구 창의 경우 창이 선택되었을 때에만 이 특성이 적용됩니다. 편집기 및 디자이너의 경우 편집기가 활성화되어 있는 마지막 MDI 자식 창일 경우 이 특성이 적용됩니다. HighPriorityAttributes 속성 값이 True이면 이 특성은 항상 적용되며 우선 순위가 가장 높습니다.

키워드를 창이나 창 요소와 연결한 다음 이를 사용하여 도움말 항목을 표시할 수 있습니다. XML Help Provider를 사용하면 사용자 지정 도움말 항목이나 URL을 표시할 수 있습니다. 자세한 내용은 VSIP(Visual Studio Industry Partner) SDK 도움말에서 "XML Help Provider 및 동적 도움말"을 참조하십시오.

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

ContextAttributesContextAttribute를 사용하면 다음 작업을 수행할 수 있습니다.

  • 키워드 이름, 값 및 형식을 추가 또는 제거

  • 키워드의 이름 및 값 가져오기

  • DTE.ContextAttributes에서 ContextAttributes 컬렉션으로서 High Priority 특성 목록 가져오기

참고:

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

예제

이 추가 기능 예제에서는 동적 도움말 자동화 모델의 다양한 멤버를 참조하고 사용하는 방법을 보여 줍니다. 이 예제에서는 솔루션 탐색기와 관련된 키워드의 이름 및 번호를 나열하고, 새로운 F1 키워드를 추가한 다음 이를 다시 제거합니다. 이 예제를 추가 기능이나 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.
    CATest(_applicationObject)
End Sub

Sub CATest(ByVal dte As DTE2)
    ' Get a reference to Solution Explorer.
    Dim SolnEx As Window = _applicationObject.Windows.Item(Constants. _
    vsWindowKindSolutionExplorer)
    Dim CA As ContextAttribute

    ' List the current attributes associated with Solution Explorer.
    ListAttr(SolnEx, CA)

    ' Associate a new F1 keyword to Solution Explorer.
    SolnEx.ContextAttributes.Add("ANewKeyword", "900", _
    vsContextAttributeType.vsContextAttributeLookupF1)
    ListAttr(SolnEx, CA)

    ' Delete the new F1 keyword from Solution Explorer.
    SolnEx.ContextAttributes.Item(3).Remove()
    ListAttr(SolnEx, CA)
End Sub

Sub ListAttr(ByVal SolnEx As Object, ByVal CA As ContextAttribute)
    ' Support function for CATest(). Lists the current attributes 
    ' associated with Solution Explorer.
    Dim msg As String
    msg = ""

    MsgBox("Number of context attributes in Solution Explorer: "  _
    & SolnEx.ContextAttributes.Count)
    For Each CA In SolnEx.ContextAttributes
        msg = msg & CA.Name & Chr(13)
    Next
    MsgBox(msg)
    msg = ""
End Sub
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst, ref
 System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    //  Pass the applicationObject member variable to the code example.
    CATest(_applicationObject); 
}

public void CATest( DTE2 dte ) 
{ 
    // Add-in code.
    // Get a reference to Solution Explorer.
    Window SolnEx = dte.Windows.Item
( Constants.vsWindowKindSolutionExplorer ); 
    ContextAttribute CA = null; 

    // List the current attributes associated with Solution Explorer.
    ListAttr( SolnEx, CA ); 

    // Associate a new F1 keyword to Solution Explorer.
    SolnEx.ContextAttributes.Add( "ANewKeyword",
 System.Convert.ToString(900),
 vsContextAttributeType.vsContextAttributeLookupF1 ); 
    ListAttr( SolnEx, CA ); 

    // Delete the new F1 keyword from Solution Explorer.
    SolnEx.ContextAttributes.Item( 2 ).Remove(); 
    ListAttr( SolnEx, CA ); 
} 

public void ListAttr( EnvDTE.Window SolnEx, ContextAttribute CA ) 
{ 
    // Support function for CATest(). Lists the current attributes 
    // associated with Solution Explorer.
    string msg = null; 

    MessageBox.Show
( "Number of context attributes in Solution Explorer: " 
+ SolnEx.ContextAttributes.Count); 
    foreach ( EnvDTE.ContextAttribute temp in 
SolnEx.ContextAttributes ) 
    { 
        CA = temp; 
        msg = msg + CA.Name + "\n"; 
    }
    MessageBox.Show( msg); 
    msg = ""; 
}

참고 항목

작업

방법: 창 특성 변경

방법: 추가 기능 만들기

연습: 마법사 만들기

개념

자동화 개체 모델 차트

기타 리소스

환경 창 만들기 및 제어

추가 기능 및 마법사 만들기

자동화 및 확장성 참조