Imitating drag/drop behavior from Organisation Chart

E

Eric Minkes

I have been looking in lots of places, but apparently not the correct ones.

In the organisation chart, you can drop an already existing shape on another
already existing shape, and then a connection between them is created.

I cannot figure out how to capture the drop of a shape onto another shape
(or capture the movement of a shape, for that matter).

I'm using the Visio Drawing Control inside a Windows Forms C# application.

I tried using MouseDown/MouseMove/MouseUp events, but they seem to stop
working when a shape is dragged.

Can anyone give me some pointers how to do this?

Thanks, Eric Minkes
 
D

David Parker [Visio MVP]

Try listening to FormulaChanged event, in particular PinX and PinY cells.
For hit testing, there is HitTest or SpatialNeighbors & SpatialRelations
Of course, you will ony get these events if you created a reference to the
Visio Type Libray as well as the Visio Drawing Control.
 
D

David Parker [Visio MVP]

I think that it will be better if you listen to Formula chnaged, as it fires
less often.
 
M

Mike Mueller [MSFT]

This is, in fact, the best way for determining if a shape has been moved. It
handles the case where a shape is "nudged" using the arrow keys and where a
shape is moved programmatically or using the size & position window or the
shape sheet. This is the technique used in the Organization Chart solution.

You should note that there are some additional factors to consider. If you
are trying to mimic the Org Chart "drop-on" functionality, you will probably
want to reposition the shape in response to the FormulaChanged event.
Setting the PinX/Y of the shape will fire the formulaChanged event again so
you will need to handle this case to avoid chasing your tail.
 
E

Eric Minkes

David, Mike,

Thanks for the information.

I will try to avoid chasing my tail ! :)

Regards,
Eric Minkes
 

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