Using the code librarian viewer from SDK

G

garet

I'm new to Visio/VB.net programming. I am trying to understand the
AddAdvise class. I opened up the code librarian (that came with the
SDK) and it appears there is an example. Although I am not sure how to
copy the example out into VB.NET.

What I have done thus far is create a new project and selected Visio
Add-on from VB.NET. At that point I went to the Event Sink selection
under Event Handling/AddAdvise folders. Selected all the text and
created a new class called EventSink. I then created a new module
named AddAdviseDemo and then copied/pasted the code.

This didn't seem to do anything so I added all the rest of the code
underneath the addadvise folder.

Since it didn't work I must be doing something wrong. Any ideas?

Thanks in advance for your help!
Garet
 
D

David Parker [Visio MVP]

The SDK also has some sample projects. ..

The Flowchat one demonstrates ow AddAdvise is used.
The Connects class creates the EventSink class, and adds to its EventList
The EventSink implements IVisEventProc, and can, thus, respond the events
listed.

If you follow the process, you should be able understand how the bits of
code need to fit together...
 
G

garet

Hi David,
First I want to thank you for replying. I'm sure it is something
simple and I am being dense.

I opened the flowchart example and am receiving an error similiar to
the one I got when I just copied the code out of the code librarian.
The error reads: Microsoft.Office.Interop.Excel.application is not
defined.

This natuarlly cascades into other errors such as:
C:\Program Files\Microsoft
Office\Visio11\SDK\Samples\FlowChart\VBNet\DocumentCreator.vb(12):
Namespace or type 'Excel' for the Imports
'Microsoft.Office.Interop.Excel' cannot be found.

In the pasting of the addadvise example (from the code librarian) I
got: Microsoft.Office.Interop.Visio.application is not defined.

I'm guessing this has something to do with the PIA. But I thought I
had all of these loaded. I will download them again and install again.

Any other ideas?

Thanks in advance!!!!!
Garet
 
G

garet

Hi David,
Well, I was right (for once) about the PIA issue for the Flow Chart
example. After installing Office XP PIA (Visio is 2003/Office is XP)
The example worked so I will take it apart and see if I can understand
the eventsink functionality.
It looks like the OnConnection (in connect.vb) is the first procedure
to run which calls addAdvise to initializes which events to watch for.
EventSink then sits and waits till a registered event takes place.

I've duplicated the functionality and it seems to work and I am able to
detect a shape drop.

Now onto a different question, how does it tell you are opening the VST
file? I see no mention of it. the only line that 'might' be it is in
the EventSink (handleDocumentCreate)

textInfo = GetShapeItem( _
visioApplication.ActivePage.Shapes, 1)

infoText = LoadString("UserInfoText")

But that doesn't make sense, if the text box disappears how does it
know the file was orignally created with the VST. I am missing
something but not sure what.


Thanks again for your help,
Garet
 
D

David Parker [Visio MVP]

It uses the document's Persisitent Events (tool available in the SDK)
This adds a QueueMakerEvent with argumnets to the DocumentOpen and Created
events.
This is then picked up by the add-in, which reds the argumnets, and decides
if it is the correct type of document.
 
G

garet

Cool, I was wondering what that tool was for. It seems funny that the
variables are event driven. But it works, and it works well so I
cannot argue with the result.

thanks again for all of your help! I am sure I'll be posting again,
there is plenty to learn, or more questions to ask.

take care,
garet
 

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