Loading ...
Sorry, an error occurred while loading the content.

IDTCommandTarget::QueryStatus acting strangely...

Expand Messages
  • richard_d_larson
    I have created a managed add-in for VS 2005 that adds some commands to the Item command bar on the solution explorer. Two of my commands need to be shown or
    Message 1 of 3 , Feb 1, 2006
    • 0 Attachment
      I have created a managed add-in for VS 2005 that adds some commands
      to the "Item" command bar on the solution explorer.

      Two of my commands need to be shown or hidden based on some logic I
      have placed in the IDTCommandTarget::QueryStatus handler for my add-
      in.

      I have noticed 2 strange behaviors:

      (1) The QueryStatus handler never gets called when I first right-
      click on an item in the solution explorer, so my display logic never
      executes, and both my commands show up (always). Once I select a
      menu-item from the command bar (mine or any other) the QueryStatus
      method starts getting called and works from then on during that Dev-
      env session.

      (2) Once the QueryStatus starts working during a session, I have
      noticed that it gets called multiple times for the same command on
      each right-click of a solution explorer item. This seems very odd.

      I am also seeing differences in how the Add-in behaves when running
      it in debug-mode vs. directly in a dev-env session. Sometimes when
      I load the add-in directly (no in debug mode) I am seeing multiple
      instances of my menu items show up in the command bars even though I
      am loading them only once.

      If anyone has any suggestions or solutions, or has seen these
      behaviors in the past, please let me know as I have been unable to
      explain them or work around them.

      Thanks ahead of time!
      Rich Larson
    • Carlos J. Quintero
      Hi Rich, I have seen #2 (multiple calls) although maybe not only with context menus (not sure now) but as long as your QueryStatus is ultra-fast, there should
      Message 2 of 3 , Feb 2, 2006
      • 0 Attachment
        Hi Rich,

        I have seen #2 (multiple calls) although maybe not only with context menus (not sure now) but as
        long as your QueryStatus is ultra-fast, there should be no problem with that.

        There is a new EnvDTE80.Commands2.UpdateCommandUI(performImmediately) method in VS 2005, but I
        don´t know if it will help you.

        Another approach is to learn a bit how that is done in VS 2005 SDK.

        Best regards,

        Carlos J. Quintero

        MZ-Tools: Productivity add-ins for Visual Studio
        You can code, design and document much faster:
        http://www.mztools.com



        > -----Mensaje original-----
        > De: vsnetaddin@yahoogroups.com
        > [mailto:vsnetaddin@yahoogroups.com] En nombre de richard_d_larson
        > Enviado el: jueves, 02 de febrero de 2006 01:32
        > Para: vsnetaddin@yahoogroups.com
        > Asunto: [vsnetaddin] IDTCommandTarget::QueryStatus acting strangely...
        >
        >
        > I have created a managed add-in for VS 2005 that adds some commands
        > to the "Item" command bar on the solution explorer.
        >
        > Two of my commands need to be shown or hidden based on some logic I
        > have placed in the IDTCommandTarget::QueryStatus handler for my add-
        > in.
        >
        > I have noticed 2 strange behaviors:
        >
        > (1) The QueryStatus handler never gets called when I first right-
        > click on an item in the solution explorer, so my display logic never
        > executes, and both my commands show up (always). Once I select a
        > menu-item from the command bar (mine or any other) the QueryStatus
        > method starts getting called and works from then on during that Dev-
        > env session.
        >
        > (2) Once the QueryStatus starts working during a session, I have
        > noticed that it gets called multiple times for the same command on
        > each right-click of a solution explorer item. This seems very odd.
        >
        > I am also seeing differences in how the Add-in behaves when running
        > it in debug-mode vs. directly in a dev-env session. Sometimes when
        > I load the add-in directly (no in debug mode) I am seeing multiple
        > instances of my menu items show up in the command bars even though I
        > am loading them only once.
        >
        > If anyone has any suggestions or solutions, or has seen these
        > behaviors in the past, please let me know as I have been unable to
        > explain them or work around them.
        >
        > Thanks ahead of time!
        > Rich Larson
        >
      • richard_d_larson
        Thanks for the fast reply Carlos! I ll look into the UpdateCommandUI() call to see if that fixes the issue. I ll let you know. Also, my QueryStatus logic is
        Message 3 of 3 , Feb 2, 2006
        • 0 Attachment
          Thanks for the fast reply Carlos!

          I'll look into the UpdateCommandUI() call to see if that fixes the
          issue. I'll let you know.

          Also, my QueryStatus logic is pretty fast, so I'm not too worried
          about the multiple calls. I was just hoping that someone knew the
          reason why this was happening.

          Thanks again for the info Carlos. If anyone else out there has some
          ideas I'd be very interested in hearing them.

          Thanks!

          Rich Larson

          --- In vsnetaddin@yahoogroups.com, "Carlos J. Quintero"
          <carlosq@...> wrote:
          >
          > Hi Rich,
          >
          > I have seen #2 (multiple calls) although maybe not only with
          context menus (not sure now) but as
          > long as your QueryStatus is ultra-fast, there should be no problem
          with that.
          >
          > There is a new EnvDTE80.Commands2.UpdateCommandUI
          (performImmediately) method in VS 2005, but I
          > don´t know if it will help you.
          >
          > Another approach is to learn a bit how that is done in VS 2005 SDK.
          >
          > Best regards,
          >
          > Carlos J. Quintero
          >
          > MZ-Tools: Productivity add-ins for Visual Studio
          > You can code, design and document much faster:
          > http://www.mztools.com
          >
          >
          >
          > > -----Mensaje original-----
          > > De: vsnetaddin@yahoogroups.com
          > > [mailto:vsnetaddin@yahoogroups.com] En nombre de richard_d_larson
          > > Enviado el: jueves, 02 de febrero de 2006 01:32
          > > Para: vsnetaddin@yahoogroups.com
          > > Asunto: [vsnetaddin] IDTCommandTarget::QueryStatus acting
          strangely...
          > >
          > >
          > > I have created a managed add-in for VS 2005 that adds some
          commands
          > > to the "Item" command bar on the solution explorer.
          > >
          > > Two of my commands need to be shown or hidden based on some
          logic I
          > > have placed in the IDTCommandTarget::QueryStatus handler for my
          add-
          > > in.
          > >
          > > I have noticed 2 strange behaviors:
          > >
          > > (1) The QueryStatus handler never gets called when I first right-
          > > click on an item in the solution explorer, so my display logic
          never
          > > executes, and both my commands show up (always). Once I select
          a
          > > menu-item from the command bar (mine or any other) the
          QueryStatus
          > > method starts getting called and works from then on during that
          Dev-
          > > env session.
          > >
          > > (2) Once the QueryStatus starts working during a session, I have
          > > noticed that it gets called multiple times for the same command
          on
          > > each right-click of a solution explorer item. This seems very
          odd.
          > >
          > > I am also seeing differences in how the Add-in behaves when
          running
          > > it in debug-mode vs. directly in a dev-env session. Sometimes
          when
          > > I load the add-in directly (no in debug mode) I am seeing
          multiple
          > > instances of my menu items show up in the command bars even
          though I
          > > am loading them only once.
          > >
          > > If anyone has any suggestions or solutions, or has seen these
          > > behaviors in the past, please let me know as I have been unable
          to
          > > explain them or work around them.
          > >
          > > Thanks ahead of time!
          > > Rich Larson
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.