CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

处理文档集合事件 (.NET)

2023-1-1 09:07| 发布者: admin| 查看: 428| 评论: 0|来自: AutoCAD

DocumentCollection对象事件用于响应应用程序中打开的文档。events(非同类对象事件)将保持注册状态,直到 AutoCAD 关闭或取消注册为止。DocumentCollectionDocument

以下事件可用于对象:DocumentCollection

文档已激活

激活文档窗口时触发。

文档激活已更改

在停用或销毁活动文档窗口后触发。

文档成为当前

当文档窗口设置为当前且与上一个活动文档窗口不同时触发。

文档已创建

创建文档窗口后触发。在创建新图形或打开现有图形后发生。

文档创建已启动

在创建文档窗口之前触发。在创建新图形或打开现有图形之前发生。

文档创建已取消

在取消创建新图形或打开现有图形的请求时触发。

文档已销毁

在销毁文档窗口并删除其关联的数据库对象之前触发。

文档锁定模式已更改

在文档的锁定模式更改后触发。

文档锁定模式更改否决

锁定模式更改被否决后触发。

文档锁定模式将更改

在更改文档的锁定模式之前触发。

文档待激活

在文档即将激活时触发。

文档待停用

在文档即将停用时触发。

待销毁的文档

在文档即将销毁时触发。

启用文档集合对象事件

下面的示例使用 theevent 来指示何时激活了绘图窗口。事件发生时,将显示一个消息框,其中包含已激活的图形的名称。DocumentActivated

VB.NET

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

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

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 15:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部