DocumentCollection オブジェクト イベントは、アプリケーションでのドキュメントを開く操作への応答に使用されます。DocumentCollection イベントは Document オブジェクト イベントとは異なり、AutoCAD がシャットダウンされるまで、または登録解除されるまで、登録されたままになります。
DocumentCollection オブジェクトでは次のイベントを使用できます。
ドキュメント ウィンドウがアクティブになった時点で発生します。
アクティブなドキュメント ウィンドウが非アクティブ化または破棄された後で発生します。
ドキュメント ウィンドウが現在のウィンドウに設定され、それまでのアクティブなドキュメント ウィンドウとは異なるときに発生します。
ドキュメント ウィンドウが作成されると発生します。新しい図面が作成されるか、既存の図面が開かれた後で発生します。
ドキュメント ウィンドウが作成される直前に発生します。新しい図面が作成されるか、既存の図面が開かれる前に発生します。
新しい図面を作成する要求または既存の図面を開く要求が取り消されると発生します。
ドキュメント ウィンドウが破棄され、関連付けられているデータベース オブジェクトが削除される前に発生します。
ドキュメントのロック モードが変更された後で発生します。
ロック モードの変更が拒否された後で発生します。
ドキュメントのロック モードが変更される前に発生します。
ドキュメントがアクティブ化される直前に発生します。
ドキュメントが非アクティブ化される直前に発生します。
ドキュメントが破棄される直前に発生します。
次の例では、DocumentActivated イベントを使用して、図面ウィンドウがアクティブになったことを示します。イベントが発生すると、アクティブになった図面の名前を含むメッセージ ボックスが表示されます。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
<CommandMethod("AddDocColEvent")> _
Public Sub AddDocColEvent()
AddHandler Application.DocumentManager.DocumentActivated, _
AddressOf docColDocAct
End Sub
<CommandMethod("RemoveDocColEvent")> _
Public Sub RemoveDocColEvent()
RemoveHandler Application.DocumentManager.DocumentActivated, _
AddressOf docColDocAct
End Sub
Public Sub docColDocAct(ByVal senderObj As Object, _
ByVal docColDocActEvtArgs As DocumentCollectionEventArgs)
Application.ShowAlertDialog(docColDocActEvtArgs.Document.Name & _
" was activated.")
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
[CommandMethod("AddDocColEvent")]
public void AddDocColEvent()
{
Application.DocumentManager.DocumentActivated +=
new DocumentCollectionEventHandler(docColDocAct);
}
[CommandMethod("RemoveDocColEvent")]
public void RemoveDocColEvent()
{
Application.DocumentManager.DocumentActivated -=
new DocumentCollectionEventHandler(docColDocAct);
}
public void docColDocAct(object senderObj,
DocumentCollectionEventArgs docColDocActEvtArgs)
{
Application.ShowAlertDialog(docColDocActEvtArgs.Document.Name +
" was activated.");
}
Private Sub AcadDocument_Activate()
' This example intercepts the Document Activate event.
MsgBox ThisDrawing.Name & " was activated."
End Sub