Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Public Class Class1
'为命令 AddCOMEvent 和 RemoveCOMEvent定义公有变量
Dim acAppCom As AcadApplication
<CommandMethod("AddCOMEvent")> _
Public Sub AddCOMEvent()
'将appComBeginFileDrop 注册到Application.AcadApplication.BeginFileDrop
acAppCom = Application.AcadApplication
AddHandler acAppCom.BeginFileDrop, AddressOf appComBeginFileDrop
End Sub
<CommandMethod("RemoveCOMEvent")> _
Public Sub RemoveCOMEvent()
'解除注册
RemoveHandler acAppCom.BeginFileDrop, AddressOf appComBeginFileDrop
acAppCom = Nothing
End Sub
Public Sub appComBeginFileDrop(ByVal strFileName As String, _
ByRef bCancel As Boolean)
'当DWG文件被托放到AutoCAD上时,显示对话框确认是否打开。
If System.Windows.Forms.MessageBox.Show("AutoCAD 将要打开:" & _
strFileName & vbLf & _
"你确定要打开它吗?", _
"DWG 文件拖放", _
System.Windows.Forms.MessageBoxButtons.YesNo) = _
System.Windows.Forms.DialogResult.No Then
bCancel = True
End If
End Sub
End Class
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Public Class Class1
'为命令 AddCOMEvent 和 RemoveCOMEvent定义公有变量
Dim acAppCom As AcadApplication
<CommandMethod("AddCOMEvent")> _
Public Sub AddCOMEvent()
'将appComBeginFileDrop 注册到Application.AcadApplication.BeginFileDrop
acAppCom = Application.AcadApplication
AddHandler acAppCom.BeginFileDrop, AddressOf appComBeginFileDrop
End Sub
<CommandMethod("RemoveCOMEvent")> _
Public Sub RemoveCOMEvent()
'解除注册
RemoveHandler acAppCom.BeginFileDrop, AddressOf appComBeginFileDrop
acAppCom = Nothing
End Sub
Public Sub appComBeginFileDrop(ByVal strFileName As String, _
ByRef bCancel As Boolean)
'当DWG文件被托放到AutoCAD上时,显示对话框确认是否打开。
If System.Windows.Forms.MessageBox.Show("AutoCAD 将要打开:" & _
strFileName & vbLf & _
"你确定要打开它吗?", _
"DWG 文件拖放", _
System.Windows.Forms.MessageBoxButtons.YesNo) = _
System.Windows.Forms.DialogResult.No Then
bCancel = True
End If
End Sub
End Class
[本日志由 tiancao1001 于 2009-11-03 02:28 PM 编辑]
|
tiancao1001 于 2009-11-04 10:25 AM 发表评论:
是这样的:对于AutoCAD 2010,Application类中封装了BeginDoubleClick事件,AutoCAD 2009及以下,是没这个事件的。所以想写个双击事件是不可能的了,但是现在很多用人不用高版本的AutoCAD。
发表评论 - 不要忘了输入验证码哦! |