Events in Managed C++: Problem with Events, WindowEvents

别等时光非礼了梦想. 提交于 2020-01-06 04:32:28

问题


Working on a VisStudio 2008 addin, using managed C++ (C++/CLR in the New Project wizard).

In the OnConnection() function, I want to add a handler to the WindowEvents collection.

When I do this:
// Hook up events
EnvDTE::Events ^ events = _applicationObject->Events;
EnvDTE::WindowEvents ^winEvents = events->WindowEvents();

I get an error message:
error C2660: 'EnvDTE::Events::WindowEvents::get' : function does not take 0 arguments

In the Object Browser I find this:
public EnvDTE.WindowEvents WindowEvents(EnvDTE.Window WindowFilter = null) { get; }

Thanks for any hints about what I'm doing wrong...


回答1:


Try

EnvDTE::WindowEvents ^winEvents = events->WindowEvents;

without the (). WindowEvents is a property not a method.




回答2:


Found the answer:

EnvDTE::Events ^ events = _applicationObject->Events;
_winEvents = events->WindowEvents[nullptr];

Note the square brackets...



来源:https://stackoverflow.com/questions/1075212/events-in-managed-c-problem-with-events-windowevents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!