QueryCancelConvertToGroup event not working...

D

dani

Hi there

I was trying to handle the QueryCancelConvertToGroup event which I need
in my own add-in.

I have registered the event using the AddAdvise method, but then, when
grouping two shapes, I never get the QueryCancelConvertToGroup event,
just the "shape added" event.

Then I tried it with the event monitor which comes with the Visio 2002
SDK, opened a new document and tried to group two rectangles, but again,
the QueryCancelConvertToGroup event was not fired.

But surprisingly, the QueryCancelUngroup was fired when ungrouping the
rectangles again.

Does anyone have an explanation for this?

below is the output of the event monitor....

thanks for any help

Daniel

1049 >EnterScope Group [1051;0;Group]
1050 | ShapeAdded Sheet.3 [/doc=1 /page=1 /shape=Sheet.3]
1050 | SelectionAdded Sheet.3 [/doc=1 /page=1]
1051 | ShapeParentChanged Sheet.1-> Sheet.3 [/doc=1 /page=1 /shape=Sheet.1]
1051 | ShapeParentChanged Sheet.2-> Sheet.3 [/doc=1 /page=1 /shape=Sheet.2]
1052 <ExitScope Group [1051;0;Group]

1296 >EnterScope Ungroup [1052;0;Ungroup]
1298 | QueryCancelUngroup Sheet.3 [/doc=1 /page=1]
<-------- Event Monitor's response is: False (don't cancel)
1300 | ShapeParentChanged Sheet.1-> ThePage [/doc=1 /page=1 /shape=Sheet.1]
1300 | ShapeParentChanged Sheet.2-> ThePage [/doc=1 /page=1 /shape=Sheet.2]
1301 | BeforeSelectionDelete Sheet.3 [/doc=1 /page=1]
1303 | BeforeShapeDelete Sheet.3 [/doc=1 /page=1 /shape=Sheet.3]
1304 | MustFlushScopeEnded
1305 <ExitScope Ungroup [1052;0;Ungroup]
 
M

Markus Breugst

Hi Daniel,

there is a difference between "group" and "convert to group". (If you go to
the menu "Shape -> Grouping", you will see both menu items.)

In our application, we also have to cancel a group operation, and we do this
by catching the "ShapeParentChange" event. This event is thrown when shapes
are grouped. In this case, we simply invoke the operation "Ungroup()" on the
shape which is given as eventSubject.

Best regards,
Markus
 
D

dani

Hi Markus

Sounds good. I'm going to try that right now.
Thanks for your help, you saved me much time...

Daniel
 
D

dani

Hi Markus

I was trying what you told me.
But somehow this didn't want to work. Always when I want to ungroup the
eventSubject in the event handler, it says the operation is currently
disabled. It seems that the event handler has to be finished before I
can ungroup the shape...

I also tried it by catching the exitScope event of Group and then trying
to Undo, but the same problem here.

What am I doing wrong??

Daniel
 
D

dani

OK, I think I've got it.

When catching the exitScope-Event of the Group-Scope, I can ungroup the
current selection (which is the group I wanted to ungroup)...
 
M

Markus Breugst

Hi Daniel,

sorry, my fault. Try the Ungroup with the parent of the eventSubject shape.

IVShape _shape = eventSubject as IVShape;
IVShape _parentShape = _shape.Parent as IVShape;
.....
_parentShape.Ungroup();

Best regards,
Markus
 

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