Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Override the default project item Delete Command?

$
0
0
Hi,

I would like to override the Delete command for a project item in the visual studio isolated shell. Basically I would like to show my own dialog giving more options, to either permanently delete a file or simply remove it from the project. I have had limited success at overriding the command.

I followed the procedure mentionned here http://forums.msdn.microsoft.com/en-US/vsx/thread/04833459-07cf-4b31-b5b6-0c91c45331ec/ , here http://forums.msdn.microsoft.com/en-US/vsx/thread/67d03f4b-50f1-47ab-b289-972166b58e4f/ and here http://msdn.microsoft.com/en-us/library/bb491719.aspx

I was able to add a custom command to the project node, but I am not able to find the guid for the project item delete command. I have tried using the VSCTPower Toy to locate the guids, but searching for the delete revealed a lot of guids that didn't work.

Here is what I tried:

In the projectpackage.cs file:
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;  
            if (null != mcs)  
            {  
                // Create the command for the menu item.  
                CommandID menuCommandID = new CommandID(Microsoft.VisualStudio.VSConstants.GUID_VSStandardCommandSet97, (int)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.Delete);  
                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID);  
                mcs.AddCommand(menuItem);  
            } 

Here is my Project.vsct file:
<?xml version="1.0" encoding="utf-8"?>  
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">  
 
  <!--This is the file that defines the IDs for all the commands exposed by VisualStudio. --> 
  <Extern href="stdidcmd.h"/>  
 
  <!--This header contains the command ids for the menus provided by the shell. --> 
  <Extern href="vsshlids.h"/>  
 
  <!--Definition of some VSCT specific constants. In this sample we use it for the IDs inside the guidOfficeIcon group. --> 
  <Extern href="msobtnid.h"/>  
 
  <Commands package="guidMyProjectPkgString">  
 
 
    <Groups> 
 
      <Group guid="guidMyProjectCmdSet" id="MyMenuGroup" priority="0x0600">  
        <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>  
      </Group> 
 
    </Groups> 
      
    <Buttons> 
   
      <Button guid="guidMyProjectCmdSet" id="cmdidMyDelete" priority="0x0100" type="Button">  
        <Parent guid="guidMyProjectCmdSet" id="MyMenuGroup" /> 
        <Icon guid="guidImages" id="bmpPic1" /> 
        <Strings> 
          <CommandName>cmdidMyDelete</CommandName> 
          <ButtonText>My Delete</ButtonText> 
        </Strings> 
      </Button> 
 
 
    </Buttons> 
     
    <!--The bitmaps section is used to define the bitmaps that are used for the commands.--> 
    <Bitmaps> 
   
      <Bitmap guid="guidImages" href="Resources\Images_32bit.bmp" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>  
 
    </Bitmaps> 
   
  </Commands> 
 
  <UsedCommands> 
    <UsedCommand guid="guidVSStd97" id="cmdidDelete"/>  
  </UsedCommands> 
 
  <Symbols> 
    <!-- This is the package guid. --> 
    <GuidSymbol name="guidMyProjectPkgString" value="{3ec03295-5726-4566-911d-95df1f155c2d}" /> 
      
    <!-- This is the guid used to group the menu commands together --> 
    <GuidSymbol name="guidMyProjectCmdSet" value="{88bc05d1-a081-483c-a1d1-f3e692aae54f}">  
 
      <IDSymbol name="MyMenuGroup" value="0x1020" /> 
      <IDSymbol name="cmdidMyDelete" value="0x0100" /> 
    </GuidSymbol> 
      
    <GuidSymbol name="guidImages" value="{ac6a431b-41a2-4565-b3b6-5200109aad7f}" > 
      <IDSymbol name="bmpPic1" value="1" /> 
      <IDSymbol name="bmpPic2" value="2" /> 
      <IDSymbol name="bmpPicSearch" value="3" /> 
      <IDSymbol name="bmpPicX" value="4" /> 
      <IDSymbol name="bmpPicArrows" value="5" /> 
    </GuidSymbol> 
  </Symbols> 
 
</CommandTable> 

I am unable to get MenuItemCallback to be called whenever I click on delete for a project item. If I replace the CommandID code with the following:
CommandID menuCommandID = new CommandID(GuidList.guidMyCmdSet, (int)PkgCmdIDList.cmdidMyDelete);
and click on the My Delete Menu item, I am able to get the MenuItemCallBack. 
This is not what I want, to as I want to override the Delete command not add a new command to the menu. 

Does anyone know how to do this, or have tips for using the VSCTPower Toy?

Thanks

Eric

Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>