Here is the module I am using to accomplish doubleclick event handling:
' System
Imports Microsoft.Win32
Imports System.Reflection
' AutoCAD
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports acApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
' AutoCAD Interop
Imports acOp = Autodesk.AutoCAD.Interop
Imports acOpCom = Autodesk.AutoCAD.Interop.Common
Module ModDoubleClick
Private acDoc As acOp.AcadDocument
Private handlerAdded As Boolean = False
Public Sub eventDoubleClick()
Try
If handlerAdded = False Then
acApp.SetSystemVariable("DBLCLKEDIT", 0)
If acDoc Is Nothing Then
acDoc = CType(acApp.DocumentManager.MdiActiveDocument.AcadDocument, _
Autodesk.AutoCAD.Interop.AcadDocument)
AddHandler acDoc.BeginDoubleClick, AddressOf callback_DoubleClick
End If
handlerAdded = True
End If
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
Finally
acApp.SetSystemVariable("DBLCLKEDIT", 1)
End Try
End Sub
Private Sub callback_DoubleClick(ByVal PickPoint As Object)
Dim activeDoc As Document = acApp.DocumentManager.MdiActiveDocument
Dim prmtSel As PromptSelectionResult = activeDoc.Editor.GetSelection()
Using docLock As DocumentLock = activeDoc.LockDocument()
If prmtSel.Status <> PromptStatus.OK Then Return
If prmtSel.Value.Count <> 1 Then Return
Dim id As Autodesk.AutoCAD.DatabaseServices.ObjectId = _
prmtSel.Value(0).ObjectId
Using acTrans As Autodesk.AutoCAD.DatabaseServices.Transaction = _
activeDoc.TransactionManager.StartTransaction()
Dim dbObj As Autodesk.AutoCAD.DatabaseServices.DBObject = _
acTrans.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
Dim ent As Autodesk.AutoCAD.DatabaseServices.Entity = _
TryCast(dbObj, Autodesk.AutoCAD.DatabaseServices.Entity)
If ent Is Nothing Then
Return
Else
Dim blockRef As Autodesk.AutoCAD.DatabaseServices.BlockReference = _
TryCast(ent, Autodesk.AutoCAD.DatabaseServices.BlockReference)
If blockRef Is Nothing Then
Return
Else
activeDoc.Editor.WriteMessage(blockRef.Name)
End If
End If
acTrans.Commit()
End Using
End Using
End Sub
End Module
And the Commands class, from which my vb.net form is generated, as well as where the ModDoubleClick.eventDoubleClick() method is called:
Public Class Commands
' Component for displaying the Mass Straight Conveyor form
<CommandMethod("mst")> _
Public Shared Sub massStraight()
Try
' Call this to override default block dblclk event handler
ModDoubleClick.eventDoubleClick()
' Display the mass straight form
Dim cForm As New frmMassStraight
acApp.ShowModalDialog(cForm)
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Class
To execute, I start AutoCAD 2010, and type 'mst' into the command bar to run the command which both launches my form and as well 'supposedly' applies doubleclick handler.
After form execution has drawn a block, I doubleclick on the block and the AutoCAD block Attributes Editor still appears.
Really frustrating, isn't it? No end in sight, still hoping for some insight as to why the module isn't doing what it's supposed to do, override the default AutoCAD doubleclick event for blocks (with attributes)...