Cannot get clicked shape in drawing control

P

Phil Hazell

Hi,

I am trying to implement determining the shape clicked on via the spatialsearch code demonstrated in the MSDN document "Programming with the Microsoft Office Visio 2003 ActiveX Control". As soon as the SpatialSearch is called the program returns from the function and I never get to the line assigning the value to the shape.

Any ideas why this is not working for me?

Private Sub AxDrawingControl1_MouseUpEvent(ByVal sender As Object, ByVal e As AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseUpEvent) Handles AxDrawingControl1.MouseUpEvent
shpMouse = GetShape(e.x, e.y)
MsgBox(shpMouse.Name)
End Sub

Function GetShape(ByVal x As Double, ByVal y As Double) As Visio.Shape
Dim sel As Visio.Selection
sel = Me.AxDrawingControl1.Window.SpatialSearch(x, y, Visio.VisSpatialRelationCodes.visSpatialContainedIn, 0.001, Visio.VisSpatialRelationFlags.visSpatialFrontToBack)
Return sel(1)
End Function
 
P

Phil Hazell

Hi,

I have resolved this problem. The syntax in the example seems to be incorrect for Visio 2003. The SpatialSearch function now resides in the Page object, not the Window object. The correct syntax is:

Return App.ActivePage.SpatialSearch(x, y, Visio.VisSpatialRelationCodes.visSpatialContainedIn, 0.001, Visio.VisSpatialRelationFlags.visSpatialFrontToBack).Item(1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top