使用 New Add-in Wizard 创建 Visual C++/ATL 加载项项目。
生成的代码:
HRESULT hr = S_OK;
pApplication->QueryInterface(__uuidof(DTE2), (LPVOID*)&m_pDTE);
pAddInInst->QueryInterface(__uuidof(AddIn), (LPVOID*)&m_pAddInInstance);`
获取事件对象和 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) : error C2039: 'WindowActivated' : is not a member of '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”