DoubleClick的事件处理程序的引用不起作用

DoubleClick的事件处理程序的引用不起作用

本文介绍了对VsUIHierarchyWindowCmdIds.UIHWCMDID_DoubleClick的事件处理程序的引用不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2008插件中编写了以下代码


I have written the following code in my VS2008 addin

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
   _applicationObject = (DTE2)application;
   _addInInstance = (AddIn)addInInst;
   ServiceProvider sp = new ServiceProvider((IOleServiceProvider)_applicationObject);

   DTE dte = sp.GetService(typeof(DTE)) as DTE;
   private CommandEvents commandEvents

   if (dte != null) {
      commandEvents = dte.Events.get_CommandEvents(typeof(Microsoft.VisualStudio.VSConstants.VsUIHierarchyWindowCmdIds).GUID,
                                           (int)Microsoft.VisualStudio.VSConstants.VsUIHierarchyWindowCmdIds.UIHWCMDID_DoubleClick) as CommandEvents;

      commandEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(OnBeforeExecute);
   }
}

代码执行正常没有任何问题,但当我双击VS 解决方案资源管理器中的项目时,执行控件没有来到我的OnBeforeExecute方法。

我尝试使用相同的代码来执行Open( Microsoft.VisualStudio。 VSConstants VSStd97CmdID 。打开)并且工作正常。你能告诉我什么是错的吗?

问候
ShahinBasheer

The code executes fine without any problem, but when I double click on an item in VS Solution explorer, the execution control does not come to my OnBeforeExecute method.

I tried this same code for commands like Open (Microsoft.VisualStudio.VSConstants.VSStd97CmdID.Open) and it works fine. Can you please let me know what is wrong?

Regards
ShahinBasheer

推荐答案


这篇关于对VsUIHierarchyWindowCmdIds.UIHWCMDID_DoubleClick的事件处理程序的引用不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 09:03