在本指南https://msdn.microsoft.com/en-us/library/office/ff767482.aspx中,当我拖放形状时,我能够获得事件触发器。但问题是当我收到此事件触发器时,形状位置未更新到放置位置。我的问题是,在我放下它以在Visio中对其他形状的形状进行重叠检查后,如何获得形状的更新位置?
Dim strMessage As String
'Find out which event and event extension fired
Select Case nEventCode
Case visEvtCodeMouseMove
Dim strInfo As String
If (pSubjectObj.DragState = visMouseMoveDragStatesDrop) Then
strMessage = "MouseMove - dragDrop"
'Shape position is not updated to drop position here
End If
Case Else
strMessage = "Other (" & nEventCode & ")"
End Select
'Display the event name and the event code
If (Len(strMessage)) Then
Debug.Print strMessage
End If
结束功能
答案 0 :(得分:0)
在您的第一个If
语句中,主题对象应该是具有x和y属性的MouseEvent
对象(以英寸为单位)。然后,您可以使用它们搜索已放置目标形状的任何形状:
Dim evtMouse As Visio.MouseEvent
Dim selSearchShapes As Visio.Selection
...
Set evtMouse = pSubjectObj
Set selSearchShapes = evtMouse.Application.ActivePage.SpatialSearch(evtMouse.x, _
evtMouse.y, _
Visio.VisSpatialRelationCodes.visSpatialContainedIn, _
0, _
Visio.VisSpatialRelationFlags.visSpatialFrontToBack)
Debug.Print "Spatial search found: " & selSearchShapes.Count
If selSearchShapes.Count > 0 Then
Debug.Print "Spatial search - top shape: " & selSearchShapes(1).NameID
End If