![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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... Note that: EnvDTE::WindowEvents ^winEvents = events->WindowEvents; EnvDTE::WindowEvents ^winEvents = events->WindowEvents(0); both give the same error as mentioned above. |
#3
| |||
| |||
|
|
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 Note that: EnvDTE::WindowEvents ^winEvents = events->WindowEvents; EnvDTE::WindowEvents ^winEvents = events->WindowEvents(0); both give the same error as mentioned above. Have you tried WindowEvents[0] ? It's an indexed property and [] is the indexing operator in C++ and C++/CLI. |
|
.\Connect.cpp(27) : error C2664: 'EnvDTE::Events::WindowEvents::get' : cannot convert parameter 1 from 'int' to 'EnvDTE::Window ^' 1> No user-defined-conversion operator available, or |
#4
| |||
| |||
|
|
According to the VS2008 documentation: -------------------------------- Parameters WindowFilter Type: EnvDTE..::.Window Optional. If supplied, window events occur only for the specified Window. -------------------------------- It seems clear, from the error messages, that the parameter is not optional. If that is the case, how does one supply a Window filter that means "all windows"? |
#5
| |||
| |||
|
|
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 Note that: EnvDTE::WindowEvents ^winEvents = events->WindowEvents; EnvDTE::WindowEvents ^winEvents = events->WindowEvents(0); both give the same error as mentioned above. Have you tried WindowEvents[0] ? It's an indexed property and [] is the indexing operator in C++ and C++/CLI. Thanks for the reply. This code: EnvDTE::WindowEvents ^we = events->WindowEvents[0]; generates this error: .\Connect.cpp(27) : error C2664: 'EnvDTE::Events::WindowEvents::get' : cannot convert parameter 1 from 'int' to 'EnvDTE::Window ^' |
|
1> No user-defined-conversion operator available, or 1> No standard conversion exists from the boxed form of the arithmetic type to the target type 1>.\Connect.cpp(27) : error C2660: 'EnvDTE::Events::WindowEvents::get' : function does not take 0 arguments According to the VS2008 documentation: -------------------------------- Parameters WindowFilter Type: EnvDTE..::.Window Optional. If supplied, window events occur only for the specified Window. -------------------------------- It seems clear, from the error messages, that the parameter is not optional. If that is the case, how does one supply a Window filter that means "all windows"? __________ Information from ESET NOD32 Antivirus, version of virus signature database 4219 (20090705) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com |
#6
| |||
| |||
|
|
Ahh, it likes the syntax. But the parameter type is a handle and we passed a number. Try "nullptr". |
#7
| |||
| |||
|
|
Ahh, it likes the syntax. But the parameter type is a handle and we passed a number. Try "nullptr". 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 Thanks for the reply. |
#8
| |||
| |||
|
|
The syntax it likes is with square brackets... |
#9
| |||
| |||
|
|
The syntax it likes is with square brackets... Thanks, that builds. Now, adding an event handler: void CBAddIn4::Connect::WindowActivated2(EnvDTE::Window ^ lostFocus, EnvDTE::Window ^ gotFocus) { } EnvDTE::Events ^ events = _applicationObject->Events; _winEvents = events->WindowEvents[nullptr]; _winEvents->WindowActivated += gcnew EnvDTE::_dispWindowEvents_WindowActivatedEventHand ler(&CBAddIn4::Connect::WindowActivated2); Compiler error: 1>Connect.cpp 1>.\Connect.cpp(28) : error C3352: 'void CBAddIn4::Connect::WindowActivated2(EnvDTE::Window ^,EnvDTE::Window ^)' : the specified function does not match the delegate type 'void (EnvDTE::Window ^,EnvDTE::Window ^)' |
#10
| |||
| |||
|
|
Delegate creation from a non-static member function requires two parameters, one to identify the member function and one to identify the instance. Try: _winEvents->WindowActivated += gcnew EnvDTE::_dispWindowEvents_WindowActivatedEventHand ler(this, &CBAddIn4::Connect::WindowActivated2); and it's not recommended to begin variable names with an underscore, only library code should do that. Thanks for your help. My add-in is handling window events. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |