アクティブなドキュメントをパラメーターとして受け取るアドインを作成しました。そのため、アクティブなドキュメントが変更されるたびに、それを知る必要があります。そのために、DTE2 オブジェクトの「Events.DocumentEvents.DocumentOpened」イベントを使用したいと考えました。しかし問題は、アクティブなドキュメントを変更してもイベントが発生しないことです。
コード スニペットは次のとおりです。
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_applicationObject.Events.DocumentEvents.DocumentOpened += new _dispDocumentEvents_DocumentOpenedEventHandler(DocumentEvents_DocumentOpened);
...
}
void DocumentEvents_DocumentOpened(Document Document)
{
MessageBox.Show("Not called");
}
DocumentEvents も試しましたが、成功しませんでした。何か案は?