MSDN > フォーラム ホーム > Visual Studio Extensibility > Problem with Events, WindowEvents, managed C++
質問する質問する
 

回答済みProblem with Events, WindowEvents, managed C++

  • 2009年7月2日 16:48Number8 ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Hello,

    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...

回答

すべての返信

  • 2009年7月6日 9:23Wesley YaoMSFT, モデレータユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Hello,

    Actually, property WindowEvents has no default parameter, not sure why it shows on Object Browser, this is the documentation on MSDN: Events.WindowEvents Property.
    Please pass 'null' to use it.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • 2009年7月6日 11:34Number8 ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     コードあり
    Thanks for the reply.
    Doesn't the Object Browser get its information from metadata in the assembly?  It seems to be consistent with the doc you linked to:
    Parameters
    WindowFilter
    Type: EnvDTE.Window
    Optional. If supplied, window events occur only for the specified Window. 
    Reflector reports the same:  parameter is optional, default is null.

    Anyway, trying to pass a parameter:
    EnvDTE::WindowEvents ^we = events->WindowEvents(0);
    1>Compiling...
    1>Connect.cpp
    1>.\Connect.cpp(27) : error C2660: 'EnvDTE::Events::WindowEvents::get' : function does not take 0 arguments

    EnvDTE::WindowEvents ^we = events->WindowEvents(nullptr);
    
    1>Compiling...
    1>Connect.cpp
    1>.\Connect.cpp(27) : error C2660: 'EnvDTE::Events::WindowEvents::get' : function does not take 0 arguments


    Is there a possible compiler setting problem?

  • 2009年7月6日 17:31Number8 ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    Solution:
    _winEvents = events->WindowEvents[nullptr];

    (Note square brackets.)
    • 回答としてマークNumber8 2009年7月6日 17:31
    •