Ask a questionAsk a question
 

AnswerUnable to hide a command with combo-box

  • Wednesday, October 07, 2009 9:13 AMRoman R. Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I have a command with a combo-box in my unmanaged package. This command is located in the Tools menu. I try to control the visibility of this combo-box in the QueryStatus method of the package:
    void
     Update_ComboCommand(const
     CommandHandler& handler, OLECMD* prgCmds, OLECMDTEXT* pCmdText){<br />
        if
    (m_EnabledCombo) prgCmds->cmdf = OLECMDF_ENABLED | OLECMDF_SUPPORTED; else
     prgCmds->cmdf = OLECMDF_INVISIBLE | OLECMDF_SUPPORTED;<br />
    }
    
    In addition, the combo-box should be invisible if my package is not loaded. So I declare it this way:
    #define DIS_DEF         DEFAULTDISABLED | DEFAULTINVISIBLE | DYNAMICVISIBILITY

    COMBOS_BEGIN
    // Combo Box ID, Group ID, Priority, Fill Command ID, Width, Type, Flags, Button Text, Menu Text, ToolTip Text, Command Name;
    guidVsPackage2CmdSet:cmdidCombo, guidVsPackage2CmdSet:MyMenuGroup, 0x114, cmdidComboFill, 75, IndexCombo, DIS_DEF, "Package 2 Combo", "Package 2 ComboBox";
    COMBOS_END
    In practice in VS2010 when the combo-box should be invisible it is displayed as disabled, including when the package is not loaded. However, if I register my package for VS2005, the combo-box works as expected.

    I tried to change the flags of the combo-box to DEFAULTINVISIBLE | DYNAMICVISIBILITY and change the command handler this way:

    void
     Update_ComboCommand(const
     CommandHandler& handler, OLECMD* prgCmds, OLECMDTEXT* pCmdText){
        if
    (m_EnabledCombo) prgCmds->cmdf = OLECMDF_ENABLED | OLECMDF_SUPPORTED; else
     prgCmds->cmdf = OLECMDF_INVISIBLE | OLECMDF_SUPPORTED | OLECMDF_ENABLED;
    }
    
    
    but this did not yield expected results, too.

    What do I do incorrectly? Or is this a bug? This problem is reproduced with a simple example which is a modified wizard's template. The command handler is called. So I don't understand this behavior.

    Any help will be appreciated.
    Thanks,
    Roman

Answers

  • Thursday, November 05, 2009 5:09 AMPaul HarringtonMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Roman,

    I checked with the developer on the new WPF command bars feature. It should indeed be possible to control visibility of combo boxes on menus through QueryStatus. It looks like a bug in VS 2010 Beta 2. No promises, but we'll investigate a fix for the VS 2010 Release Candidate.

    Thanks for the report!

    - Paul Harrington.
    Visual Studio Platform and Ecosystem

All Replies

  • Thursday, November 05, 2009 5:09 AMPaul HarringtonMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Roman,

    I checked with the developer on the new WPF command bars feature. It should indeed be possible to control visibility of combo boxes on menus through QueryStatus. It looks like a bug in VS 2010 Beta 2. No promises, but we'll investigate a fix for the VS 2010 Release Candidate.

    Thanks for the report!

    - Paul Harrington.
    Visual Studio Platform and Ecosystem