AddAdvise and ShapeAdded event does not work in C#

B

Bertil Emmertz

Hi !

I´m running i COM Addin to Visio written in C#. I want to set up an
EventSink to catch the event ShapeAdded. I have tried to use AddAdvise but
ran into problems.

Here is the definition for AddAdvise

Event AddAdvise(short EventCode, object SinkIUnkOrIDisp, string IIDSink,
string TargetArgs);

To set up the EventCode you use VisEventCodes according to the SDK
documentation.

(short)VisEventCodes.visEvtShape + (short)VisEventCodes.visEvtAdd

The problem is that this sum is > 32767 which is the upper limit for short
(in fact the VisEventCodes.visEvtAdd in itselft is 32768). So it won´t
compile !!

So, how do I use AddAdvise to achieve my goal.

BEz
 
C

Chris Roth [MVP]

Bertil,

I know this has long been a problem in VB. I searhced through my code
libraries and found this line:
const Int16 visEvtAdd = -32768;

Give it a shot, becaue it seems to have worked for me! I just don't remember
how or why : )


--
Hope this helps,

Chris Roth
Visio MVP

www.wanderkind.com/visio
 
M

Mark Nelson [MS]

Yes, you have to do the same thing in VB.Net and C#. I believe the event
handling samples in the SDK show this constant.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

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

Bertil Emmertz

Thanks gentlemen, you solved my problem

I replaced

(short)visEventCodes.visEvtAdd with
(short)(-(int)visEventCodes.visEvtAdd)

and it worked :>)
 

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