다음을 통해 공유


방법: 추가 하 고 제거할 속성 페이지

프로젝트 디자이너는 프로젝트 속성, 설정 및 리소스를 관리 하기 위한 중앙된 위치를 제공 Visual Studio. 단일 창으로 표시 되는 Visual Studio 통합 개발 환경 (IDE)와 왼쪽에 있는 탭을 통해 액세스 하는 창의 오른쪽에 있습니다. 프로젝트 디자이너에 있는 틀 (속성 페이지 라고도 함)은 프로젝트 형식과 언어 다. 프로젝트 디자이너에 액세스할 수 있는 속성프로젝트 메뉴.

자주 프로젝트 하위 프로젝트 디자이너에서 추가 속성 페이지를 표시 해야 합니다. 마찬가지로 일부 프로젝트 하위 유형을 기본 제공 속성 페이지 제거 하도록 요구할 수 있습니다. 프로젝트 하위 중 하나를 구현 해야 합니다는 IVsHierarchy 를 재정의 하 고 인터페이스는 GetProperty 메서드. 이 메서드를 재정의 하 고 사용 하 여 propId 매개 변수 값 중 하나가 포함 된는 __VSHPROPID2 열거형을 필터링을 추가 하거나 프로젝트 속성을 제거 합니다. 예를 들어, 구성 종속성 속성 페이지에 페이지를 추가 해야 합니다. 이렇게 하려면 구성 종속성 속성 페이지를 필터링 한 다음 새 페이지를 기존 목록에 추가 해야 합니다.

추가 및 프로젝트 디자이너 속성 페이지 제거

프로젝트 디자이너에서 속성 페이지를 제거 하려면

  1. 재정의 GetProperty(uint itemId, int propId, out object property) 속성 페이지를 필터링 하 고 메서드는 clsids 목록입니다.

    Protected Overrides int GetProperty(uint itemId, int propId, out object property)
    Protected Overrides Function GetProperty(ByVal itemId As UInteger, ByVal propId As Integer, ByRef [property] As Object) As Integer
        'Use propId to filter configuration-independent property pages.
        Select Case propId
            .... 
            Case CInt(Fix(__VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList))
                'Get a semicolon-delimited list of clsids of the configuration-independent property pages
                ErrorHandler.ThrowOnFailure(MyBase.GetProperty(itemId, propId, [property]))
                   Dim propertyPagesList As String = ((String)[property]).ToUpper(CultureInfo.InvariantCulture)
                'Remove the property page here
                   ....
            ....
        End Select
            .... 
        Return MyBase.GetProperty(itemId, propId, [property])
    End Function
    
    protected override int GetProperty(uint itemId, int propId, out object property)
    {
        //Use propId to filter configuration-independent property pages.
        switch (propId)
        {
            . . . .
    
            case (int)__VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList:
                {
                    //Get a semicolon-delimited list of clsids of the configuration-independent property pages
                    ErrorHandler.ThrowOnFailure(base.GetProperty(itemId, propId, out property));
                    string propertyPagesList = ((string)property).ToUpper(CultureInfo.InvariantCulture);
                    //Remove the property page here
                    . . . .
                }
             . . . .
         }
            . . . .
        return base.GetProperty(itemId, propId, out property);
    }
    
  2. 제거는 빌드 이벤트 페이지에서 얻은 clsids 목록입니다.

    Private buildEventsPageGuid As String = "{1E78F8DB-6C07-4D61-A18F-7514010ABD56}"
    Private index As Integer = propertyPagesList.IndexOf(buildEventsPageGuid)
    If index <> -1 Then
        ' GUIDs are separated by ';' so if you remove the last GUID, also remove the last ';'
        Dim index2 As Integer = index + buildEventsPageGuid.Length + 1
        If index2 >= propertyPagesList.Length Then
            propertyPagesList = propertyPagesList.Substring(0, index).TrimEnd(";"c)
        Else
            propertyPagesList = propertyPagesList.Substring(0, index) + propertyPagesList.Substring(index2)
        End If
    End If
    'New property value
    property = propertyPagesList
    
    string buildEventsPageGuid = "{1E78F8DB-6C07-4D61-A18F-7514010ABD56}";
    int index = propertyPagesList.IndexOf(buildEventsPageGuid);
    if (index != -1)
    {
        // GUIDs are separated by ';' so if you remove the last GUID, also remove the last ';'
        int index2 = index + buildEventsPageGuid.Length + 1;
        if (index2 >= propertyPagesList.Length)
            propertyPagesList = propertyPagesList.Substring(0, index).TrimEnd(';');
        else
            propertyPagesList = propertyPagesList.Substring(0, index) + propertyPagesList.Substring(index2);
    }
    //New property value
    property = propertyPagesList;
    

프로젝트 디자이너에서 속성 페이지를 추가 하려면

  1. 추가할 속성 페이지를 만듭니다.

    Class DeployPropertyPage
            Inherits Form
            Implements Microsoft.VisualStudio.OLE.Interop.IPropertyPage
        'Summary: Return a stucture describing your property page.
        .... 
        Public Sub GetPageInfo(ByVal pPageInfo As Microsoft.VisualStudio.OLE.Interop.PROPPAGEINFO())
            Dim info As PROPPAGEINFO = New PROPPAGEINFO()
            info.cb = CUInt(Marshal.SizeOf(GetType(PROPPAGEINFO)))
            info.dwHelpContext = 0
            info.pszDocString = Nothing
            info.pszHelpFile = Nothing
            info.pszTitle = "Deployment" 'Assign tab name
            info.SIZE.cx = Me.Size.Width
            info.SIZE.cy = Me.Size.Height
            If Not pPageInfo Is Nothing AndAlso pPageInfo.Length > 0 Then
                pPageInfo(0) = info
            End If
        End Sub
    End Class
    
    class DeployPropertyPage : Form, Microsoft.VisualStudio.OLE.Interop.IPropertyPage
    {
        . . . . 
        //Summary: Return a stucture describing your property page.
        public void GetPageInfo(Microsoft.VisualStudio.OLE.Interop.PROPPAGEINFO[] pPageInfo)
        {
            PROPPAGEINFO info = new PROPPAGEINFO();
            info.cb = (uint)Marshal.SizeOf(typeof(PROPPAGEINFO));
            info.dwHelpContext = 0;
            info.pszDocString = null;
            info.pszHelpFile = null;
            info.pszTitle = "Deployment";  //Assign tab name
            info.SIZE.cx = this.Size.Width;
            info.SIZE.cy = this.Size.Height;
            if (pPageInfo != null && pPageInfo.Length > 0)
                pPageInfo[0] = info;
        }
    }
    
  2. 새 속성 페이지를 등록 합니다.

    <MSVSIP.ProvideObject(GetType(DeployPropertyPage), RegisterUsing = RegistrationMethod.CodeBase)>
    
    [MSVSIP.ProvideObject(typeof(DeployPropertyPage), RegisterUsing = RegistrationMethod.CodeBase)]
    
  3. 재정의 GetProperty(uint itemId, int propId, out object property) 속성 페이지 필터에서 얻을 수 있는 메서드는 clsids 나열 하 고 새 속성 페이지를 추가 합니다.

    Protected Overrides Function GetProperty(ByVal itemId As UInteger, ByVal propId As Integer, ByRef [property] As Object) As Integer
        'Use propId to filter configuration-dependent property pages.
        Select Case propId
            .... 
            case CInt(Fix(__VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList)):
                'Get a semicolon-delimited list of clsids of the configuration-dependent property pages.
                ErrorHandler.ThrowOnFailure(MyBase.GetProperty(itemId, propId, [property]))
                'Add the Deployment property page.
                [property] &= ";"c + GetType(DeployPropertyPage).GUID.ToString("B")
        End Select
            .... 
            Return MyBase.GetProperty(itemId, propId, [property])
    End Function
    
    protected override int GetProperty(uint itemId, int propId, out object property)
    {
        //Use propId to filter configuration-dependent property pages.
        switch (propId)
        {
            . . . .
            case (int)__VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList:
                {
                    //Get a semicolon-delimited list of clsids of the configuration-dependent property pages.
                    ErrorHandler.ThrowOnFailure(base.GetProperty(itemId, propId, out property));
                    //Add the Deployment property page.
                    property += ';' + typeof(DeployPropertyPage).GUID.ToString("B");
                }
         }
            . . . .
        return base.GetProperty(itemId, propId, out property);
    }
    

참고

이 항목에서 제공 하는 모든 코드 예제는 보다 큰 예제의 일부입니다 Visual Studio 확장성 샘플.

참고 항목

기타 리소스

프로젝트 하위