Delete shapes acrosss pages

A

Andy

I have my own page connector to link across pages. However, if I
delete either end of the off page connector I would like the other end
to be automatically deleted as well. However, if I catch the delete
in the document QueryCancelSelectionDelete event and try to delete my
shape on the other page i get an error, presumably as i am in the
process of handling a delete. The selection is passed by value so I
can't add my shape to it (not sure if a selection could contain shapes
on different pages).

Any suggestions welcomed.
 
P

Paul Herber

I have my own page connector to link across pages. However, if I
delete either end of the off page connector I would like the other end
to be automatically deleted as well. However, if I catch the delete
in the document QueryCancelSelectionDelete event and try to delete my
shape on the other page i get an error, presumably as i am in the
process of handling a delete. The selection is passed by value so I
can't add my shape to it (not sure if a selection could contain shapes
on different pages).

You're right in that a selection can only include shapes on one page.
Get the object references to both shapes before you start doing
anything to them, then do a deselect all (besides ensuring that all
your code handling selections has a non-null value), then you can
delete the referring shape, then the referred to shape, otherwise
you'll get a reference error.
 
M

Mark Nelson [MS]

As you have figured out, Visio does not let you delete a shape while
handling a delete event on another shape. When telling you about things
that Visio is about to do, the application becomes modal. You can only read
information from the drawing, not make changes. The typical solution is to
make a queue for the work you need to do and then wait until the
NoEventsPending event to process your queue.

If you want a lot more information on this, check out the Building a
Model-driven Solution talk on http://www.visioconferencecontent.com/.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Andy

I found that I can do the delete of the shape in the BeforeShapeDelete
event, rather than the QueryCancelSelectionDelete event. I have to
mark the other shape so that I can ignore handling the
BeforeShapeDelete event for it.

As you have figured out, Visio does not let you delete a shape while
handling a delete event on another shape. When telling you about things
that Visio is about to do, the application becomes modal. You can only read
information from the drawing, not make changes. The typical solution is to
make a queue for the work you need to do and then wait until the
NoEventsPending event to process your queue.

If you want a lot more information on this, check out the Building a
Model-driven Solution talk onhttp://www.visioconferencecontent.com/.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


On 14 Feb 2007 04:53:05 -0800, "Andy"
You're right in that a selection can only include shapes on one page.
Get the object references to both shapes before you start doing
anything to them, then do a deselect all (besides ensuring that all
your code handling selections has a non-null value), then you can
delete the referring shape, then the referred to shape, otherwise
you'll get a reference error.
 

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