明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2728|回复: 0

[讨论]VB.Net的事件处理

[复制链接]
发表于 2004-6-22 09:57:00 | 显示全部楼层 |阅读模式
原理,在VBA的窗体激活事件中改变USERS系统变量,VB.Net接收该事件将文档级事件处理激活到当前文档

总觉得不太妥当,有好点的办法么?

VB.Net - Module mTlsCad代码
  1. Private WithEvents pACadApp As AcadApplication = Application.AcadApplication
  2. Private WithEvents pACadDoc As AcadDocument = pACadApp.ActiveDocument
  3. Private Sub pACadApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Object) Handles pACadApp.SysVarChanged
  4. If SysvarName.ToUpper = "*USERS5" Then pACadDoc = pACadApp.ActiveDocument
  5. End Sub
  6. Private Sub pACadDoc_BeginDoubleClick(ByVal PickPoint As Object) Handles pACadDoc.BeginDoubleClick
  7. Dim ss As AcadSelectionSet
  8. ss = pACadDoc.PickfirstSelectionSet
  9. If ss.Count = 0 Then
  10. Exit Sub
  11. ElseIf ss.Count = 1 Then
  12. Select Case ss.Item(0).EntityName
  13. Case "AcDbBlockReference"
  14. If ss.Item(0).HasAttributes Then
  15. pACadDoc.SendCommand("_.eattedit" & vbCr & vbCr & vbCr)
  16. End If
  17. Case "AcDbText", "AcDbMText"
  18. pACadDoc.SendCommand("_.ddedit" & vbCr & vbCr)
  19. Case Else
  20. pACadDoc.SendCommand("_.properties" & vbCr)
  21. End Select
  22. Else
  23. pACadDoc.SendCommand("_.properties" & vbCr)
  24. End If
  25. End Sub
VBA - ThisDrawing代码
  1. Private Sub AcadDocument_Activate()
  2. Dim pUser As String
  3. pUser = ThisDrawing.GetVariable("USERS5")
  4. ThisDrawing.SetVariable "USERS5", str(Now)
  5. ThisDrawing.SetVariable "USERS5", pUser
  6. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 04:34 , Processed in 0.152887 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表