Capturing Paste via AddAdvise

E

Eric

I have an event sink handler for many Visio events. I now have a need to
capture the paste event.

I've tried this:
resultEvent = eventListDoc.AddAdvise(
***( ((short) Visio.VisEventCodes.visEvtCodeEnterScope) + (short)
Visio.VisEventCodes.visEvtShape)***
(Visio.IVisEventProc) eventSinkHandler, "", "" );

and

***( ((short) Visio.VisEventCodes.visEvtCodeEnterScope) +
(short)Visio.VisUICmds.visCmdUFEditPaste ),***

AddAdvise raises a COM exception.

What is the correct way to capture the event?

Regards,

Eric
 
E

Eric

Even this returns an exception:

resultEvent = eventListDoc.AddAdvise(

(short) Visio.VisEventCodes.visEvtCodeEnterScope,

eventSinkHandler, "", "" )

None of my other AddAdvise lines have any issues...

Thanks for your help,
 
M

Mark Nelson [MS]

AddAdvise works with one event at a time. If you want to handle multiple
events, make multiple AddAdvise calls.

For EnterScope, visEvtCodeEnterScope is the complete constant for this
event. You should not be adding visEvtShape to this. In your follow-up
post, the only thing I see wrong with your statement is the omission of a
semi-colon at the end.

Visio does not have an event for Paste. You should handle SelectionAdded
(visEvtCodeSelAdded) and then ask Visio whether you are currently in a Paste
command scope: Application.IsInScope(visCmdUFEditPaste)

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

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

Eric

Thanks Mark,

resultEvent = eventListDoc.AddAdvise(
(short) Visio.VisEventCodes.visEvtCodeSelAdded,
eventSinkHandler, "", "" );

and

case (short) Visio.VisEventCodes.visEvtCodeSelAdded :
if (doc.Application.get_IsInScope((int)Visio.VisUICmds.visCmdUFEditPaste))
{
MessageBox.Show("paste");
}

worked for me. Obviously I left out a lot of the surrounding code, but I
wanted to get an example out there in the search engines - the rest of the
code is the typical AddAdvise/EventSinkHandler code.
 

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