Installation
Simply create a directory in some convenient location, copy the Zip file
there, and unzip. This should result in several subdirectories:
...\DAVSL |
Contains units common to any DAVSL-based VSL project. |
...\otherdirs |
Contain various individual sample VSL projects |
There are no components to install.
Project Structure
Each of the samples includes an xxx.dpr project file, which in Delphi serves
to define the DLL's entry points. For a VSL this means the VisioLibMain
procedure. The dpr file, as usual with any Delphi project, specifies other files
to compile into the project (and this list can also be viewed in the Delphi
Project Manager window). Each project includes several files from
the DAVSL directory, along with one or a few others specific to the particular
VSL. A typical project looks something like this:
File category |
Directory |
Filename |
Description |
Specific to particular VSL |
...\MyVSLDir |
MyVSL.dpr |
Project file. Copy generic VSL dpr and edit the external
fielname and internal library name only. (eg: Library MyVSL;) |
MyVSL_AddOns.pas |
Unit in which to declare and implement addons. These can
provide the actual functionality too, or act simply as intermediaries to
othe objects/units where the real functionality happens. See the Architecture
discussion. (You can have more such addon units if need be -- see how
addons register themselves with the VSL object in the unit initialization
sections.) |
MyVSL_Control.pas |
Where the addons are simple intermediaries, this unit would
provide the main implementation (and of course you can have any number
more such units). |
Common to all VSLs |
...\DAVSL |
DAVAO.pas |
Translation of types and constants from VAO.h |
DAVSL.pas |
TVSL manager object; Base TAddOn object |
DAVSL_Util.pas |
Some supporting functions |
DAVSL_About |
Standard About dialog |
whereever |
Visio_TLB |
This is the Visio type library generated with Delphi Import
Type Library feature. This should either be included in the project, or in
the default Library path (such as in $(DELPHI)\Imports). The DAVSL
package includes a Visio_TLB in the ...\DAVSL directory in case you are
unfamiliar with using the Import Type Lib feature. |
Getting A Sample Running
To get a sample running, open one of the sample directories, and double click
the dpr file, or use Delphi to open it. You may need to perform one or more
of the following steps:
- Create a directory where your VSL DLLs will reside and be found by Visio,
for example ..\Visio\Solutions\MyVSLs
- Set Project > Options > Output directory accordingly
- In Project > Version Info set some version info
- Compile and verify that Delphi produced a VSL in the solution directory.
- Launch Visio, and exercise the demo according to the descriptions for the
individual demos.
- Don't forget to put Visio in Developer mode, so that the Tools >
Add-Ons menu is available.
- To run Visio and a VSL under Delphi's debugger, you will need to specify
the application to run (ie: Visio) in Delphi's Run > Parameters dialog.
You might also specify a document to load if repeatedly testing with same
doc.
Details on Individual Demos
DAVSLBeep
Trivial VSL which provides a single AddOn (function): DAVSLBeep_Beep. You can
fire this AddOn using the Tools > Add-Ons menu, or create a shape with an
Action which uses:
RUNADDON("DAVSLBeep_Beep")
Needless to say it sounds a "Beep-Beep" from the PC speaker. The
structure of the VSL project demonstrates the minimal basics for a DAVSL-style
VSL.
DAVSLColorForm
This sample demonstrates using a Delphi form as a modeless dialog to control
Visio.
- Launch Visio and drop a shape on the drawing page.
- Activate DAVSLColorForm_Open from the Tools > Add-Ons menu, the
DAVSLColorForm dialog should appear.
- Select a shape on the drawing, and use the dialog's buttons to change the
shape's fill color.
- Minimize Visio and note that the dialog minimizes too.
DAVSLShapeChange
Demonstrates supplying arguments to an AddOn (eg: using the RUNADDONWARGS
ShapeSheet function). Also demos the About feature.
- Launch Visio and open the supplied Demo_ShapeChange.vsd document
- Try the shape's right-click items (Blue-Green and 90-degrees). (Note: if
these don't immediately work, force Visio to refesh its addon cache by
selecting the Tools > Add-Ons menu item. No need to run an addon, just
listing them should be sufficient.) After applying the addon's changes, you
can restore the shape with regular Visio menus or toolbuttons.
- Inspect the shape's ShapeSheet ShapeSheet Action section to see how the
arguments are set up.
- To see description of available arguments, use Tools > Add-Ons > Run
Add-on, select DAVSLShapeChange_Color, and click About.
- Note how structure of units follows scheme described in Architecture
page.
DAVSLArgs
Demonstrates the arguments that a VSL receives, depending on how it is
called.
- Launch Visio and open the supplied DAVSLArgs.vsd drawing.
- Right-click the shape and select Args.
- The AddOn's window will show the arguments that Visio passes.
- Note that this window is modal, compared to modeless windows in other
examples.
- Note that the VSL object which parses the arguments into a TStringList
also strips of any leading slash (which Visio customarily supplies for the
default arguments.).
- See also the VSL Arguments discussion in the Technical
Notes page.
DAVSLEvents
Demonstrates how a VSL responds to Visio events (Connection Add and Delete).
- Launch Visio
- Use Tools > Add-Ons > Run Add-on and select DAVSLEvents_Show
- Create a drawing with some shapes and connectors.
- Watch the Events window as you glue and unglue connectors.
Code notes:
- Unit DAVSLEvents_Events contains a Delphi object that implements the COM
IVisioAddOnSink interface needed to receive event notifications from Visio.
- DAVisioAddonSink.tlb contains the type library for IVisioAddOnSink.
- The DAVSL_IncludeEvents unit tells Delphi to build the type library
information into the DLL. This is needed so that the DAVSLEvents_Events unit
can use a call to TAutoObjectFactory.Create to initialize an object factory
for use in creating TVisioAddOnSink objects. (Note that it is not
necessary to register this type library in the Registry.)
- DAVisioAddOnSink_TLB.pas is a standard Delphi unit generated by the Type
Library editor declaring the IVisioAddOnSink for use in Delphi (in much the
same way as Visio_TLB.pas declares the interfaces to Visio for use in
Delphi.)
- The DAVSLEvents_Control unit contains the heart of the VSL, including
hooking up and unhooking event monitoring, and handling event notifications
passed along via the VisioAddOnSink object.
- Note how the EventController object maintains its own
IVisioAddOnSink reference, despite already having a TVisioAddOnSink
reference. If this were not the case, after adding an event and then
deleting the event, the references to VisioAddOnSink would have incremented
then decremented back to zero, at which point the VisioAddOnSink would be
released. Instead, we want it to stay around even when no event objects are
actually referencing it.
Article Created: 2000-09-20 Last edit: Last edit: 00-10-30 Graham Wideman
Go to: DiagramAntics.com