Using the QueryCancelSelectionDelete event in C#

  • Thread starter Nicolas De Irisarri
  • Start date
N

Nicolas De Irisarri

Hello.

I'm trying to display an alert when a user deletes a specific shape. I
read that QueryCancelSelectionDelete could serve for this, but the
application never triggers that event. This is the code in c# I'm
working on:

//this line goes in the OnConnection method of the Add-in:
document.QueryCancelSelectionDelete += new
Visio.EDocument_QueryCancelSelectionDeleteEventHandler
(this.queryCancelSelectionDelete);

(....)

private void queryCancelSelectionDelete(Visio.Selection sel, out bool
salida)
{
salida = true;
if (sel.Count != 1 )
return;
if (MessageBox.Show ("are you sure?", MessageBoxButtons.OKCancel )
== DialogResult.Cancel)
return;
else
salida = false;
return;
}

I tried to debug it, and it doesn't stop on the event handler....
any clues??
 
M

Markus Breugst

Hello Nicolas,

I am using the AddAdvice / VisEventProc approach for catching events, and it
works without any problems.
Our application (stand-alone, not add-in) also uses the
QueryCancelSelectionDelete event for preventing the deletion of specific
shapes.

Also one reply of the following news conversation says that the AddAdvice
approach is more reliable:
"... I have found that those events don't work very well. Some
incompatibility with a managed code add-in. I would recommend using
AddAdvise for your events, with an event sink. ..."

http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&oe=UTF-8&threadm=40a25b6.0
302210935.57a04aff%40posting.google.com&rnum=3&prev=/groups%3Fq%3Dvisio%2B%2
522add-in%2522%2Bviseventproc%26hl%3Dde%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26
selm%3D40a25b6.0302210935.57a04aff%2540posting.google.com%26rnum%3D3


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