I'm writing a VSPackage and I need to have menu item with checkbox, just like on this sample image below:
I went through this msdn reference regarding .vsct files, bud didn't fine any information explaining how to do it. What I have now is standard menu item with icon and text (code sample from MyPackage.vsct file):
<Buttons>
<Button guid="guidMyPackageCmdSet" id="cmdidMyPackage" type="Button">
<Icon guid="guidImages" id="myPackageBitmap" />
<CommandFlag>TextChanges</CommandFlag>
<CommandFlag>DontCache</CommandFlag>
<CommandFlag>FixMenuController</CommandFlag>
<Strings>
<ButtonText>MyPackage</ButtonText>
</Strings>
</Button>
</Buttons>
I need this additional checkbox. How to do it?
The properties like
Checked
,Visible
,Enabled
orSupported
can´t be defined via theVSCT
file. You need a command handler that controls the command´s state. I´ve created a base class that wraps the creation of theOleMenuCommand
instance and handles the command´sBeforeQueryStatus
event. This is a slimmed version of my implementation, but it will give you an idea how to solve it...The
CommandHandler
class allows to control the state of any menu command. Just derive new handler implementations from it and override theOnExecute
andOnQueryStatus
methods, like...