locked
Solution Explorer Addin RRS feed

  • Question

  • I have added a new CommandBar to the Solution Explorer. I want to provider custom settings and be able to enable/disable them for each source files independently. How am i able to change/show the state (whether the settings are enabled or not)  of the CommandBar for each source file? I understand that it is possible to query a command state with IDTCommandTarget.QueryStatus. But how is it possible to keep track of all states when the command is being used with multiple source files.

    Any help is pretty much appreciated.
    Sunday, February 28, 2010 12:11 PM

Answers

  • Hello,

    If I understand correctly, you have added a toolbar or context menu entries to the Solution Explorer toolwindow and you want to enable its commands (buttons or menu entries) based on the selected file(s) in the Solution Explorer.

    If so, the answer is that the IDTCommandTarget.QueryStatus method of your add-in will be called whenever an event happens that may change the state of commands, such a change in the selection of the Solution Explorer. It is up to your add-in (in its IDTCommandTarget.QueryStatus) to get the selected file(s) in the Solution Explorer and to determine if its commands should be enabled or disabled.

    For more information see:

    HOWTO: Controlling the state of command in a Visual Studio add-in
    http://www.mztools.com/resources_vsnet_addins.aspx

    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    • Marked as answer by Nancy Shao Monday, March 8, 2010 3:07 AM
    Monday, March 1, 2010 9:22 AM
  • Per Carlos' earlier response, you'll want to use IDTCommandTarget.QueryStatus. Your QueryStatus implementation will need to determine which file(s) are currently selected, and then return the appropriate StatusOption.

    Sincerely,


    Ed Dore
    Monday, March 1, 2010 5:39 PM

All replies

  • Hello,

    If I understand correctly, you have added a toolbar or context menu entries to the Solution Explorer toolwindow and you want to enable its commands (buttons or menu entries) based on the selected file(s) in the Solution Explorer.

    If so, the answer is that the IDTCommandTarget.QueryStatus method of your add-in will be called whenever an event happens that may change the state of commands, such a change in the selection of the Solution Explorer. It is up to your add-in (in its IDTCommandTarget.QueryStatus) to get the selected file(s) in the Solution Explorer and to determine if its commands should be enabled or disabled.

    For more information see:

    HOWTO: Controlling the state of command in a Visual Studio add-in
    http://www.mztools.com/resources_vsnet_addins.aspx

    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    • Marked as answer by Nancy Shao Monday, March 8, 2010 3:07 AM
    Monday, March 1, 2010 9:22 AM
  • Hi Charlos,

    thanks for your fast reply. Basically all i want to know is, how i am able to show the user whether a specific option is currently enabled or disabled for the selected file.

    Kind Regards,

    Egon
    Monday, March 1, 2010 11:53 AM
  • Per Carlos' earlier response, you'll want to use IDTCommandTarget.QueryStatus. Your QueryStatus implementation will need to determine which file(s) are currently selected, and then return the appropriate StatusOption.

    Sincerely,


    Ed Dore
    Monday, March 1, 2010 5:39 PM