处理 DocumentCollection 事件 (.NET)
DocumentCollection对象事件用于响应应用程序中打开的文档。 与对象事件不同,事件在AutoCAD关闭或取消注册之前会保持注册状态。DocumentCollectionDocument 以下事件可用于对象:DocumentCollection
启用 DocumentCollection 对象事件下面的示例使用该事件来指示何时激活绘图窗口。事件发生时,将显示一个消息框,其中包含已激活图形的名称。DocumentActivated VB.NETImports 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
C#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.");
}
VBA/ActiveX 代码参考Private Sub AcadDocument_Activate()
' This example intercepts the Document Activate event.
MsgBox ThisDrawing.Name & " was activated."
End Sub
相关概念父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 15:16
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.