新規アドイン ウィザードを使用して、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'