locked
How to change solution node's caption RRS feed

  • Question

  • Hi,

    I am creating a source control provider to integrate git with Visual Studio. http://gitscc.codeplex.com/. It would be useful to displaythe  branch name on the solution node, e.g. to show 

    Solution 'Solution1' (4 projects) (master)

    I tried solHier.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Caption, out caption); It returns caption of null. And solHier.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Caption, caption) does not change the caption.

    Is there a way to change the solution node's caption?

    Thanks,

    yysun

    Saturday, May 29, 2010 10:30 PM

Answers

  • Hi,

    I noticed that VS is pretty aggressive about resetting the solution node caption back to what it wants.  So I trap the property change event and set it back to my own value (but remember to protect against recursion!!).
    So it boils down to two steps:

    a) set the value using 
        m_WithinSettingSolutionNodeCaption = true;
        IVsSolution.SetProperty((int)__VSPROPID.VSPROPID_SolutionNodeCaption, my-new-caption-string );
        m_WithinSettingSolutionNodeCaption = false;

    b) handle the event for the solution node property changing, and making sure it is what YOU want (but protecting against recursion):

            int IVsShellPropertyEvents.OnShellPropertyChange(int propid, object var)
            {
                if (propid == (int)__VSPROPID.VSPROPID_SolutionNodeCaption)
                {
                    if (!m_WithinSettingSolutionNodeCaption)
                    {
                        this.MyOwnSetSolutionNodeCaption();
                    }
                    else
                    ....

    Hope this helps,
    Reed Shilts

    • Proposed as answer by Reed Shilts Monday, June 7, 2010 6:21 PM
    • Marked as answer by yysun Tuesday, June 8, 2010 12:54 PM
    Monday, June 7, 2010 6:21 PM

All replies

  • Hi,

    I noticed that VS is pretty aggressive about resetting the solution node caption back to what it wants.  So I trap the property change event and set it back to my own value (but remember to protect against recursion!!).
    So it boils down to two steps:

    a) set the value using 
        m_WithinSettingSolutionNodeCaption = true;
        IVsSolution.SetProperty((int)__VSPROPID.VSPROPID_SolutionNodeCaption, my-new-caption-string );
        m_WithinSettingSolutionNodeCaption = false;

    b) handle the event for the solution node property changing, and making sure it is what YOU want (but protecting against recursion):

            int IVsShellPropertyEvents.OnShellPropertyChange(int propid, object var)
            {
                if (propid == (int)__VSPROPID.VSPROPID_SolutionNodeCaption)
                {
                    if (!m_WithinSettingSolutionNodeCaption)
                    {
                        this.MyOwnSetSolutionNodeCaption();
                    }
                    else
                    ....

    Hope this helps,
    Reed Shilts

    • Proposed as answer by Reed Shilts Monday, June 7, 2010 6:21 PM
    • Marked as answer by yysun Tuesday, June 8, 2010 12:54 PM
    Monday, June 7, 2010 6:21 PM
  • Thank you very much Reed Shilts.

    yysun

    Tuesday, June 8, 2010 12:54 PM