雪山飞狐_lzh 发表于 2004-6-22 09:57:00

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

原理,在VBA的窗体激活事件中改变USERS系统变量,VB.Net接收该事件将文档级事件处理激活到当前文档

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

VB.Net - Module mTlsCad代码
Private WithEvents pACadApp As AcadApplication = Application.AcadApplication
Private WithEvents pACadDoc As AcadDocument = pACadApp.ActiveDocument
Private Sub pACadApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Object) Handles pACadApp.SysVarChanged
If SysvarName.ToUpper = "*USERS5" Then pACadDoc = pACadApp.ActiveDocument
End Sub

Private Sub pACadDoc_BeginDoubleClick(ByVal PickPoint As Object) Handles pACadDoc.BeginDoubleClick
Dim ss As AcadSelectionSet
ss = pACadDoc.PickfirstSelectionSet
If ss.Count = 0 Then
Exit Sub
ElseIf ss.Count = 1 Then
Select Case ss.Item(0).EntityName
Case "AcDbBlockReference"
If ss.Item(0).HasAttributes Then
pACadDoc.SendCommand("_.eattedit" & vbCr & vbCr & vbCr)
End If
Case "AcDbText", "AcDbMText"
pACadDoc.SendCommand("_.ddedit" & vbCr & vbCr)
Case Else
pACadDoc.SendCommand("_.properties" & vbCr)
End Select
Else
pACadDoc.SendCommand("_.properties" & vbCr)
End If

End Sub

VBA - ThisDrawing代码
Private Sub AcadDocument_Activate()
Dim pUser As String
pUser = ThisDrawing.GetVariable("USERS5")
ThisDrawing.SetVariable "USERS5", str(Now)
ThisDrawing.SetVariable "USERS5", pUser
End Sub
页: [1]
查看完整版本: [讨论]VB.Net的事件处理