Multiple connects in ConnectionsDeleted event

J

J Kallay

The ConnectionsDeleted and ConnectionsAdded events both pass a Connects
collection. However, I haven't identified a single situation in which that
collection contains more than one Connect object, with neither 1D nor 2D
glue. In circumstances where one would expect a single event with multiple
Connect objects, instead multiple ConnectionsAdded/Deleted events are
raised. This not only makes the Connects parameter (as opposed to a single
Connect object) unnecessary, it can be quite inconvenient. Consider, for
example, the case where a user drags a connector, thereby breaking the glue
at both ends. Supposed we are maintaining a logical model using connectors
(such as in a flowchart, org chart, or brainstorming diagram). The Connects
parameter only provides information about one of the two shapes that the
connector connects. The connector itself already has an empty Connects
collection, so that can't be interrogated. The only way to find out that a
logical connection was broken between two shapes is to save information
about the first Connect object, wait for the second ConnectionsDeleted
event, and check whether the same connector is involved.

So, what IS the point of passing a Connects collection to these event
handlers?
 
J

JuneTheSecond

I do not know when multiple conect or disconect
event raised. Even in such a case below,
two times of single disconnect event are raised.
It seems Connects.Count is always 1 in the event proc.
I also wonder when multiple comects are returned
at one disconnect event.

Private WithEvents myPage As Visio.Page

Sub test()
Set myPage = ActivePage
Dim shp As Visio.Shape
Set shp = ActivePage.Shapes("Connector")
ActiveWindow.Select shp, visSelect
Application.ActiveWindow.Selection.Move 0#, -1#

End Sub

Private Sub myPage_ConnectionsDeleted(ByVal Connects As IVConnects)
Dim I As Integer
Dim N As Integer
Dim msg As String
N = Connects.Count
MsgBox N
For I = 1 To N
msg = msg & vbCrLf & Connects(I).ToSheet.Name
Next
MsgBox msg

End Sub
 

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