The entire process of queueing marker events and setting up a MarkerEvent
EventHandler took some time for me to understand. Just understood the whole
thing
. Thanks for that info about the QueueMarkerEvent function. I am now
being able to send events to my C# code from the shapesheet :-D.
As you mentioned some more documentation would've been helpful, but alls
well that ends well
... that you for u're prompt response.
Regards,
Mayank
PS - If anyone one this Discussion Group comes across this thread and needs
help with some sample code then I can send it out ... just reply to this
thread
.
"Mark Nelson [MS]" wrote:
> This is a great question and one that we should try to provide more detailed
> sample code for in the SDK.
>
> If you have Visio 2003, you fire a Marker event from the Shapesheet using
> the QueueMarkerEvent function. You do not need RunAddonWarg. You pass an
> argument string in QueueMarkerEvent that your Addin can recognize when it
> gets the Marker event. This is how you know that the Marker event is from
> your shape and not some other Marker event.
>
> Next you need to register for the Marker event in your addin. Visio
> provides two mechanisms for signing up for an event. First is the
> "WithEvents" approach which is similar to the Windows Forms model of writing
> code behind specific events for controls - like Command Buttons. This is
> the easier approach for languages like VB or VBA, but it is not very
> performant. I believe you can do something similar in C# using delegates,
> but I don't know the code to achieve that.
>
> The second mechanism is "AddAdvise" and is the recommended approach for C++
> and managed code or wherever performance is critical. Here you get the
> EventList of the Visio application object and call AddAdvise to sign up for
> the Marker event (event code = visEvtApp+visEvtMarker). As part of the
> process, you implement the IVisEventProc interface in order to expose a
> function that Visio will call when the event is fired. There is sample code
> for AddAdvise in the SDK that should make this much clearer.
>
> We are in the process of creating more documentation around COM Addin
> development using managed code. Please let me know what is still confusing,
> and I'll try to get some answers.
>
> --
> Mark Nelson
> Office Graphics - Visio
> Microsoft Corporation
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "unerklarlich" <[email protected]> wrote in message
> news:[email protected]...
> > Hi,
> >
> > I am writing a COM Addin for Visio in C#. The test code is connecting to
> > Visio and Loading a custom toolbar.
> >
> > I now need to be able to trigger my COM Addin from the shapesheet of the
> > shapes in my stencil. I am using RUNADDONWARG in the Shape Sheet cell to
> > run
> > the QUEUEMARKEREVENT Addon.
> >
> > I then came across some code
> > (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vmt/VMT_Lesson_2_3365.asp)
> > which illustrates how the COM Addin should listen to a MarkerEvent.
> >
> > Does anyone know how this line of code would translate to C#?
> >
> > Private WithEvents visioApplication As Application
> >
> > Thanks,
> > Mayank
>
>
>