ATL、VS2008 扩展:向 WindowEvents 添加事件处理程序
使用新建插件向导创建 Visual C++ / ATL 插件项目。
生成的代码:
HRESULT hr = S_OK;
pApplication->QueryInterface(__uuidof(DTE2), (LPVOID*)&m_pDTE);
pAddInInst->QueryInterface(__uuidof(AddIn), (LPVOID*)&m_pAddInInstance);`
获取Events对象和WindowEvents:
m_pDTE->get_Events(&m_pEvents);
m_pEvents->get_WindowEvents(0, &m_pWinEvents);
如何添加事件处理程序?
if (NULL != m_pWinEvents) {
m_pWinEvents += ????
}
感谢您的任何提示或参考...
更新,尝试 Alien01 的建议:
m_pWinEvents->WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated);
1>编译...
1>Connect.cpp
1>c:\work\visstudio_addin\cbaddin3\cbaddin3\connect.cpp(43) : 错误 C2039: 'WindowActivated' : 不是 'EnvDTE::_WindowEvents' 的成员
1> c:\work\visstudio_addin\cbaddin3\cbaddin3\debug\dte80a.tlh(1006) :参见“EnvDTE::_WindowEvents”的声明
1>c:\work\visstudio_addin\cbaddin3\cbaddin3\connect.cpp(43):错误 C2061:语法错误:标识符“_dispWindowEvents_WindowActivatedEventHandler”
Used the New Add-in Wizard to create a Visual C++ / ATL add-in project.
Generated code:
HRESULT hr = S_OK;
pApplication->QueryInterface(__uuidof(DTE2), (LPVOID*)&m_pDTE);
pAddInInst->QueryInterface(__uuidof(AddIn), (LPVOID*)&m_pAddInInstance);`
Get the Events object, and the WindowEvents:
m_pDTE->get_Events(&m_pEvents);
m_pEvents->get_WindowEvents(0, &m_pWinEvents);
How to add an event handler?
if (NULL != m_pWinEvents) {
m_pWinEvents += ????
}
Thanks for any hints or references...
UPDATE, trying Alien01's suggestion:
m_pWinEvents->WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated);
1>Compiling...
1>Connect.cpp
1>c:\work\visstudio_addin\cbaddin3\cbaddin3\connect.cpp(43) : error C2039: 'WindowActivated' : is not a member of 'EnvDTE::_WindowEvents'
1> c:\work\visstudio_addin\cbaddin3\cbaddin3\debug\dte80a.tlh(1006) : see declaration of 'EnvDTE::_WindowEvents'
1>c:\work\visstudio_addin\cbaddin3\cbaddin3\connect.cpp(43) : error C2061: syntax error : identifier '_dispWindowEvents_WindowActivatedEventHandler'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
然后定义处理程序
and then define handler