The following tips are intended as a very quick introduction on how to use MetaDraw. What is presented here basically scratches the surface of what you can do, but it should give a good feel for how easy the control is to work with and should help you get started.
To load in an image into the main picture ( drawing area) the VB Syntax would be:
MetaDRAW.LoadPicture FName$, Pic_Picture
where FName is a string specifying the full path to the file.
To load as a background, first load as main picture ( as above), then copy to the background by setting the BackPicture property to the Picture property, and now remove from the foreground by calling Clear. Finally set the PictureOptions property so the background scrolls and zooms with the main drawing layer.
- Creating an Image
To add a graphic element to the overall image, use the AddObject method.
MDraw1.AddObject ObjType%, X1&, Y1&, X2&, Y2&
Where the object type is
|1 - Line||6 - Pie (sector)|
|2 - Rectangle||7 - Chord|
|3 - Rounded Rectangle||8 - Polyline|
|4 - Ellipse (circle)||9 - Polygon|
|5 - Arc||10 - Text|
X1, Y1, X2, Y2 are long integers from 0 to 1000 (the default coordinate system)
- Adding Text
To add text, use the AddObject method to add a text object, then specify the text property.
MDraw1.AddObject OT_Text, x1, y1, x2, y2
MDraw1.Text = "some text"
MDraw1.FontName = "arial"
MDraw1.FontSize = 10
- Adding Graphics
To add graphic elements use AddObject and then specify additional parameters.
MDraw1.AddObject OT_Rectangle, 100, 100, 200, 200
MDraw1.LineWidth = 2
MDraw1.FillStyle = 3
MDraw1.ObjVisible = True
Additional properties and methods allow merging of images, changing the number and placement of points in a polygon/polyline...
- End user Drawing
To allow end user drawing just set the EditMode MDraw1.EditMode = editmodevalue where editmodevalue can be
|0 - View Only||6 - Pie (sector)|
|1 - Line||7 - Chord|
|2 - Rectangle||8 - Polyline|
|3 - Rounded Rectangle||9 - Polygon|
|4 - Ellipse (circle)||10 - Text|
|5 - Arc||11 - Allow Selection, Resize and Drag|
|12 - Rotate|
The user then just clicks/drags the mouse to draw.
- Scrolling and Zooming
To Zoom in or out, change PicXSize/PicYSize
MDraw1.PicXSize = ScaleFactor * MDraw1.OrigWidth
MDraw1.PicYSize = ScaleFactor * MDraw1.OrigHeight
To Scroll programmatically just set the PicXOfs and PicYOfs properties.
Every object in MetaDraw may be created as a HotSpot. This means that MetaDraw will generate a unique event when the mouse moves over the hotspot, or when the hotspot is clicked.
To make an object in MetaDraw into a hotspot, or Hitable object - set the ObjHotSpot property. This may be done when the object is first added to the image or when it is selected (programmatically or by an end user).
Note that each object may also be assigned a string type Tag - this can be used to identify the object or to help determine what text should be shown or action taken when the hotspot is activated.
Each object may also be set to be invisible - for hotspots this is helpful if you don't actually want to display show the border of the hotspot area. The ObjVisible property is only used when in read-only mode (MetaDraw.EditMode = 0).
MetaDraw.AddObject OT_Rectangle, X1, Y1, X2, Y2
MetaDraw.ObjHotSpot = OS_CURSOR + OS_HOTSPOT + OS_CLICK
MetaDraw.ObjTag = "Sales here are 500"
MetaDraw.ObjVisible = False
In response to mouse movement over a HotSpot, MetaDraw will trigger an On_HotSpot event. In response to clicking on a Hitable object, MetaDraw will trigger a HitObject event.
Sub MDraw_HitObject(X As Integer, Y As Integer)
- More on Hotspots - worfking with HS Editor
For more information on how to quickly create Hotspots using the HS Editor Utility
included with MetaDraw see Quick Tips on Hotspots
- Anything Else
To do anything else - just ask.
Click on Support
For real power, try MetaDraw 3, download MetaDraw 3 install kit and see what it can do for you!
MetaDraw is a serious tool, but beyond exceptional reliability and flexibility - it's also easy to use and really alot of fun (but don't tell your boss).