efan2000发表于2003-10-1 0:02:00自己做了个,可以看看效果。
在VBA中实现鼠标事件
该组件可以实现鼠标的按下、弹起、双击和移动的事件捕捉。
注意:Enabled属性设置为True表示允许事件的触发,之后一定要将其设置为Fa
奇怪,
ThisDrawing.ModelSpace(0).TextString = Round(ehObj.ConvertScreenToWorldX(X, Y) + 0.0000000001, 4) & ", " & Round(ehObj.ConvertScreenToWorldY(X, Y) + 0.0000000001, 4)
在这个1.dwg中会出现不支持TextString属性或方法的错误.
在其它文件或新建文件中却正常运行.
删除1.dwg中的对象后也能正常运行.
始终没找到原因.
- Option Explicit
- Private WithEvents ehObj As EFHook.Hook
- Private Sub CommandButton1_Click()
- On Error GoTo ErrTrap
- Me.Hide
- Set ehObj = New Hook
- ehObj.Enabled = True
- ThisDrawing.Utility.GetPoint
- ehObj.Enabled = False
- Set ehObj = Nothing
- Me.Show
- Exit Sub
-
- ErrTrap:
- ehObj.Enabled = False
- Set ehObj = Nothing
- Unload Me
- End Sub
- Private Sub ehObj_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
- ThisDrawing.ModelSpace(0).TextString = Round(ehObj.ConvertScreenToWorldX(X, Y) + 0.0000000001, 4) & ", " & Round(ehObj.ConvertScreenToWorldY(X, Y) + 0.0000000001, 4)
- ThisDrawing.ModelSpace(0).Update
- End Sub
|