What is MetaDraw ?

MetaDraw is a special purpose vector or object oriented image manipulation control. MetaDraw looks like a standard picture box on your form, but offers unique support for the creation, editing and display of images and diagrams, composed of multiple image elements such as lines, shapes, text and other images. MetaDraw is ideal for applications requiring the drawing and/or moving graphical objects, such as Cad / Drawing, Layout, Mapping, and Diagramming. The ability to manipulate individual elements within an image at real time make it suitable for Data Presentation, Animation and Interactive Graphic Interfaces. MetaDraw is also specially designed to allow you to tag individual graphic objects for HyperGraphic/HotSpot applications.

MetaDraw features include;

  • Scroll and Zoom Images by code or by mouse action
  • Container Control Support - scroll and zoom child controls along with an image.
  • Vector / Object Oriented Image Editing - act on individual elements of a picture
    • Create pictures built from individual graphic objects: - text, bitmaps, shapes, floodfill.
    • Select, Move, ReSize, Rotate, Change attributes ( color, line styles, fill patterns, etc )
    • Full Programmatic Control
    • End User Drawing with Mouse
    • UnDo and Redo Changes
      • Polyline / Polygon Manipulation
      • Group and Ungroup elements, manipulate groups as a single element.
  • Rotation at any angle
  • Internet Support – Link hotspots to Internet URL's for automatic Web navigation.
  • HotSpot/HyperGraphics support
  • Capture clicks or mouse moves through hotspot shapes
  • Assign data to individual elements for identification and information display
  • Diagraming
  • Diagram Links - automatically updated to as connected objects are moved
  • Specify arrow head style, text labels, straight or segmented links,
  • Properties to set connecting line color, thickness and style
  • User Defined Coordinate System - Grid Display and Alignment
  • Merge and Layout Images from multiple sources.
  • Selective Display – hide or show individual elements within an image
  • Save and Load to a Variety of Image Formats
    The whole picture, or any part, can be exported as a metafile( WMF or EMF), bitmap (BMP), compressed image ( JPG or PNG), icon (ICO), or MetaDraw's own compact format vector format ( MDP). DXF format is supported for users with optional DXF License.
  • Load Pictures directly from the Internet
  • Print to any specified device - even to the Windows Desktop or another Window.
  • Drag & Drop from Windows Explorer, OLE Drag Drop and VB -and-drop sources.
  • Transparent, Gradient or Bitmap Background
  • Enhanced Graphic Effects : shadows, gradient filling
  • Transparency support for bitmaps


Potential Applications of MetaDraw

Diagramming / Flow Charts

Link objects built into MetaDraw make it ideal for diagramming. Users (or application code) can connect any objects with link lines which maintain the connection between elements of the diagram as the individual elements are moved around. Links may have distinct arrow heads, line styles, line colors, even hidden tag values describing the nature of the link. Common applications include tracking product and/or waste flow within a production cycle, and software flow charts.

Layout, Floor Plans

One of the more popular uses of MetaDraw is to create layout diagrams, often for the purpose of creating Seating or Furniture arrangements, or to sketch accident scenes, or to keep track of the location of corporate staff or resources. It's easy to display a map in the background and allow users to drag around graphic elements representing chairs, or people, or anything else.

Data Mapping

MetaDraw is frequently used to associate points on a map (geographic, anatomic, or basically any two dimensional space) with information to be stored in a database. With MetaDraw you can set up your own coordinate system and populate the image programmatically with information from your database. Object Tags on each element of the overall image can be used to hold database record ID's such that a user's click can quickly retrieve appropriate data. Users may also be allowed to add graphic elements, which event is then trapped to add new data in a database.

With MetaDraw you may even dispense with traditional database storage altogether. MetaDraw can store multiple object tags for each graphic element in the image - Such tags are the equivalent of database fields. You can even search for elements based on their tags. MetaDraw's MDP format preserves both the image and the tags acting as a complete storage system for all your information needs.

Interactive Graphic Interfaces

MetaDraw can be used as the engine for an interactive graphic interface. Populate (or allow end-users to populate) the control with graphic objects that can be moved around on the screen (by dragging or by programmatic manipulation), resized, colored, ... A great way to present information - a great way to interact with users.

You can even construct graphic elements to represent buttons, add a hotspot and process the click. Such buttons can be any graphic element with any shape.

Viewers

You can use MetaDraw as a simple image viewer or as a full featured Graphic Editor. The control looks just like a picturebox on your screen. As a viewer, MetaDraw not only quickly displays the entire image and supports scroll and zoom, but also uniquely allows you show or hide individual MetaFile records.

Graphic Editing & Annotation

You can use internal features of the MetaDraw control to create and edit pictures. MetaDraw includes all the standard edit modes of a stand-alone draw package. New images can be easily created or an existing image can be loaded and manipulated at run-time. The user can add new graphic elements, Delete portions of an old image, move objects around or change their attributes (size, color, orientation, etc.).

You can easily change the color of any rectangle, text or other object. Objects can be grouped, ungrouped, moved in back or in front of other objects, or even dragged around on the screen.

HyperGraphics

MetaDraw is a wonderful tool for creating HyperGraphic applications. Any object (Metafile record or group of records) can be declared as a HotSpot. MetaDraw will automatically change the mouse cursor when it is moved over a tagged HotSpot and will generate a special HotSpot click event when clicking on such an object.

We even include our own Picture and HotSpot editor application (a stand-alone EXE) with the MetaDraw control. Pictures with HotSpot objects can be saved in a file, then loaded and displayed. All hotspots will be saved with objects.

Animations

The ability to manipulate individual elements of the picture in real-time, provide exciting opportunities for Animation within MetaDraw. Rather than redrawing a complete image, simply update those portions relevant to the movement. Move lines or shapes, Hide or show other elements, Move elements behind or in front of other elements.


On-Line Help

MetaDraw has an on-line Help system that includes all the information contained in this guide. To access Help on a MetaDraw property or event, highlight it in the properties (events) list window at design time and press F1. If it does not appear, you have probably installed OCX and Help files in different directories. Move MDRAW30.CHM file to the right directory and try again.

The given help file can be started manually, as you would start any other application. Simply select "MetaDraw Help" from the MetaDraw group of the Windows Start Menu, or from Windows Explorer. double-click on the desired help file name.


HotSpot Editor (HSEditor)

A MetaFile HotSpot Editor application, HS Editor, has been included to help you build metafiles and assign hotspots.

The Visual Basic source code to this application is available as a separate option.

Please note that HSEditor MAY not be distributed with your application except through separate arrangement with Bennet-Tec.


License Options

Several options are available when purchasing a MetaDraw development license. Most features supported by MetaDraw are available to developers with the base level license. Certain features may however require one of the optional license add-ons.

DXF Support

The DXF Support license adds support for saving and loading images in 2-d DXF file format. DXF Format is a common format used by many commercial CAD applications.

( See appendix "DXF Support Notes" for details on DXF support )

Vectorization Support

The Vectorization Support License allows MetaDraw to convert a raster ( bitmap) image to a vector image. For example an image of a map made up of different colored regions will be converted to an image where each colored region is an independent polygon object within MetaDraw.

Diagram Arrange Support

The Diagram Arrange license provides for an intelligent "optimization" of a diagram layout. The functionality of Diagram Arrange is provided through a single easy to use method call, ArrangeObjects. ` This function repositions linked objects to minimize link crossovers, and can also layout unlinked objects in a rectangular grid.

Subscription Features Support

The Subscription License option provides support for New features introduced to MetaDraw 3 after formal release of MetaDraw 3 These features will not affect already compiled applications ( all future editions of MetaDraw 3 will be backward compatible) but will be available for use by developers purchasing the Subscription License.

Subscription License holders will also receive FREE UPGRADES to major new MetaDraw editions for 1 year from date of purchase of MetaDraw 3 and Subscription License.


Supported Development Environments

MetaDraw 3 OCX has been designed for use under any programming environments supporting ActiveX controls. (A limited VBX edition is separately available for developers requiring 16 bit support).

MetaDraw has been specifically designed and tested for compatibility with Visual Basic (including VB.Net), Visual C++, Delphi, FoxPro, and MS Access

MetaDraw may also be used within a Web page (ASP or HTML) for browsing under IE or other browsers supporting ActiveX controls.

Customers have also reported success using MetaDraw in many other development environments such as APL, Clarion, CTD 2000 /Centura Team Developer 2000, PowerBuilder, Oracle Forms and Progress.

MetaDraw is in general designed to be used within development environments which produce compiled (.EXE) applications. Distributing projects built in development environments which do not produce compiled EXE applications (MS Word, Excel, and other VBA environments) may require end-users to purchase MetaDraw licenses. Exceptions (not requiring end-user licensing) are HTML pages and Access applications distributed as MDE files. Please contact Bennet-Tec with any questions on this topic.


Supported Operating Systems

MetaDraw 3 OCX is supported under Windows 95, 98, NT 4, ME, 2000, and XP operating systems.


Distributing Applications

When you create and distribute an application that uses MetaDraw, you should include the appropriate OCX file (MDRAW30.OCX) with your application and install it on the end-user's PC in the WINDOWS\SYSTEM or any other directory where DLLs can be found. The OCX files must also be Registered upon installation in the Windows System Registry.

MetaDraw dependencies (Microsoft DLL's required for proper operation of MetaDraw) are identified in the dependency file MDRAW30.DEP included with the MetaDraw installation.

Applications built using Vectorization, Diagram Arrange, or Clear Edge License support features should also include the appropriate DLL:

Vectorization | BTVector.dll
Automated Diagram Arrange | BTOA.DLL
ClearEdge Support | ClearEdge.DLL

There are no Run-Time Costs, no Royalties or Distribution Costs, no End-User Licenses required for individuals running compiled EXE applications, or accessing web pages which make use of MetaDraw. Note that Access developers should make sure to distribute projects as MDE files, not as MDB files. End-users working with MDB files will require individual MetaDraw licenses.


Installation

Requirements

MetaDraw 3 OCX is supported under Windows 95, 98, NT 3.51, NT 4, ME, 2000, and XP operating systems

There are no special requirements regarding CPU speed or memory size. You will need up to 1.5 M of free disk space for the full MetaDraw installation and about 300K for minimal installation. Note that OCX file is not that large itself - most of the space is taken up by help files, examples, bitmaps, etc.

To install MetaDraw onto your hard disk:

Start Microsoft Windows.

  1. Insert the MetaDraw distribution disk in your floppy drive.
  2. From program Manager, select the File menu and choose Run command.
  3. Type a:\Install or b:\Install, depending upon where you put the MetaDraw disk.

Normally, the Setup program copies all files to the METADRAW\ directory and associated subdirectories. However, you may prefer to put the OCX file in a different directory.

More:

Installation files

Evaluation Mode

License Registration


Installation files

Your installation Kit will include the following files:

File | Description
MDRAW30.OCX | The MetaDraw 3.0 Active X control
MDRAW30.CHM | The help file
READ 1ST.DOC | ** Important Introduction - Getting Started with MetaDraw
HISTORY.TXT | History of changes since introduction of MetaDraw 3
HSEDITOR.EXE | HotSpot Editor Utility included for use by MetaDraw developers
SAMPLES.VC\ | Sample applications for Visual C++ users. There is a MetaDraw.h file in this directory that contains global MetaDraw constants definitions.
SAMPLES.VB\ | Sample applications for Visual Basic users. Note that the BAS files are located in this directory.
SAMPLES.VB_NET\ | Sample applications for VB.Net WinForms users.
SAMPLES.DP\ | Sample applications for Borland Delphi users.
Internet\ | Sample applications for Web Developers


Evaluation Mode

Prior to license registration MetaDraw may be used in demonstration / evaluation mode for up to 30 day from the date of installation. During this time you will see a demonstration note / license warning in the background of the MetaDraw control.


License Registration

After installing MetaDraw you should Register your license.

Please remember that each license is valid for only one individual. Each individual working on a MetaDraw based project requires a separate license – even if working on parts of the project not directly related to MetaDraw or simply compiling or reviewing code If your activities require MetaDraw to be loaded into memory within a software development environment ( such as VB, VC, Delphi, VBA, etc) then you need a developer license. Please contact Bennet-Tec at Support_License@Bennet-Tec.Com if you have any questions on this. Note that Multi-User and Site License discounts are available.

Please refer to the License Registration Document you receive when you order MetaDraw for instructions on how to register your license. Additional information regarding licensing including frequently asked questions is available on the Bennet-Tec web site.


Sample Applications

Several sample applications have been prepared for users of Visual Basic, Delphi, Visual C, and Internet samples. Our samples may be found in the appropriate directories: SAMPLES.VB, SAMPLES.DP, SAMPLES.VC and INTERNET. These projects illustrate many of MetaDraw's features which may be instructive when getting started with MetaDraw.


Using MetaDraw in Visual Basic

This section provides basic information to get you started using MetaDraw in Visual Basic.

More:

Getting started in Visual Basic 4.0, 5 or 6

Getting started in Visual Basic 7 - VB.Net WinForms


Getting started in Visual Basic 4.0, 5 or 6

To begin using the MetaDraw control in Visual Basic 4, 5 or 6, you must add the control it to your toolbox.

To add the MetaDraw control to the Visual Basic toolbox:

  1. Start Visual Basic
  2. From Visual Basic 4, select the Tools/Custom Controls menu.
    From Visual Basic 5 or 6 select the Project/ Add Components menu.
    The Custom Controls dialog box appears.
  3. Select the check box next to Bennet-Tec MetaDraw control in the Available Controls box. If there is no MetaDraw Custom Control in the Available Controls box, choose the Browse button. In the Browse dialog box search the directory that contains MetaDraw files on your hard disk and choose the control file (MDRAW30.OCX).
  4. When you click the OK button, the control will be added to the toolbox.

You can now access the MetaDraw control from the Visual Basic toolbox.

You can configure Visual Basic so that the MetaDraw control is loaded automatically when you start a new project in Visual Basic.

To configure Visual Basic to load MetaDraw automatically:

  1. Start Visual Basic and open AUTO32LD.VBP.
  2. Add the MetaDraw control to the project list as described above.
  3. Choose Save Project from the File menu.


Getting started in Visual Basic 7 - VB.Net WinForms

Limitations

Drag and Drop – Microsoft Access does not support Standard Drag/Drop operations from one ActiveX control to another. The following MetaDraw properties and events are therefore not supported within Access: Drag Method, DragDrop Event, DragOver Event.

OLE DragDrop may be used to support dragging between MetaDraw and other controls.


Using MetaDraw in C++

This section provides basic information to get you started using MetaDraw in C++ environments.

More:

Getting started in Visual C++ 4, 5 or 6


Getting started in Visual C++ 4, 5 or 6

Before using MetaDraw OCX with Visual C++ you should read the following chapters:

  1. "OLE Controls" chapter in the "Programming with MFC: Encyclopedia"
  2. "COleControl" chapter in the "Class Library Reference"
  3. "Using OLE Controls in a Dialog Box" section of the "Using the Dialog Editor" chapter in the "Visual C++ User's Guide"
  4. "CONTROLS: MFC-Based OLE Controls" in the "OLE Control Samples"

To place MetaDraw OCX on the dialog editor Controls toolbar in the Microsoft Developer Studio, you must first add the MetaDraw OCX to your project in Component Gallery. Once inserted, the MetaDraw OCX appears on the dialog editor Controls toolbar and can be dragged to the dialog box that you are constructing.

To add MetaDraw OCX to the project:

  1. From the Insert menu, choose Component.
    The Component Gallery dialog box appears.
  2. Select the MetaDraw Control by clicking the control icon in the OLE Controls tab page of the Component Gallery window.
  3. Choose the Insert button.
  4. An icon [image] representing MetaDraw Control installed appears on the dialog editor Controls toolbar.
Note: You can also insert MetaDraw Control using the right-mouse menu (Insert OLE Control item). However, this method inserts the control as a stand-alone control without the wrapper class.

Using properties & methods

To access MetaDraw's properties and methods you can use the wrapper class, which is generated by Developer studio when you insert the MetaDraw Control from the Component Gallery (usually, it is CMDraw).

To get or set a MetaDraw property you can use the corresponding member function of the CMDraw class. The name of the function is the same as the name of property you want to get/set, but it has prefix 'Get' to get property or 'Set' to set property.

CPicture pic = lpMDraw->GetPicture();
short picLeft = lpMDraw->GetPicLeft();
// lpMDraw is a pointer to an instance of the CMDraw class
// for the corresponding MetaDraw Control box.

lpMDraw->SetCurrent(OBJ_SELECTED);
lpMDraw->SetLineWidth(12.5);

You can use a MetaDraw's method as a member function of the CMDraw class. For example, to load a picture into MetaDraw Control box:

lpMDraw->LoadPicture("C:\PICTURES\MY_PICT.BMP", 0, 0)
Handling events

The window that is a parent of the MetaDraw control receives all event messages. You should add all event handlers that you need in the message map of parent window of the MetaDraw control.

To do this you should follow these steps:

  1. In Developer studio, choose Class Wizard from the View menu.
  2. In the Class Wizard dialog box, choose the Message Maps tab.
  3. In the Class Name combo box choose the class whose window contains the MetaDraw control.
  4. In Object IDs list box choose the ID of the MetaDraw control.
  5. In Messages list box select the event you want to handle.
  6. Press Add Function button and type the correspondent name of your function for the selected event.

After that, you should fill all event handler functions you have just added.


Using MetaDraw in Delphi

This section provides basic information to get you started using MetaDraw in the Borland Delphi environment.

More:

Getting started in Delphi 2.0


Getting started in Delphi 2.0

Before using MetaDraw OCX with Delphi you should read the chapter:

  • "Using components and code" Chapter 2 in the Borland Delphi User's Guide.

To add the MetaDraw Control to the project:

  1. From the Component menu choose Install…
    The Install Components dialog box appears.
  2. Click the Add button to open the Add Module dialog box.
  3. Type the full pathname to the MDRAWOCX.PAS file or use the Browse button, to go to the MetaDraw directory and choose the MDRAWOCX.PAS file, then choose OK.
  4. Press the OK button in the Install Components dialog box to rebuild the Delphi's component library, and install the MetaDraw OCX component on the Component palette.
Note: Be sure that MDRAW30.OCX is registered in Windows environment. Otherwise, from the Components menu select the Install menu command. In the Install Components dialog click the OCX button. In the Import OLE Control dialog box click the Register button. In the Register OLE Control dialog box locate the MDRAW30.OCX file and click the Open button to register it.

Note: Don't install MDRAW30.OCX using the OCX button. If you do this, you will not be able to access some MetaDraw's features.

Required files for Delphi 2.0 Applications are below:

  • MDRAWOCX.PAS - declaration and implementation of the TMetaDraw class and constant declarations.
  • MDRAWOCX.DCR - resources required for MDRAWOCX.PAS


Using MetaDraw in Microsoft Access

This section provides basic information to get you started using MetaDraw in an Access development environment. Note that Access requires use of the OCX edition of MetaDraw.

Before using MetaDraw OCX with Access 7.0 you should read the chapter:

  • "Using OLE Custom Controls" Chapter 15, in Building Applications with Microsoft Access for Windows 95.

To add the MetaDraw Control to a form or report:

  1. In form or report Design view, click Custom Control on the Insert menu.
    The Insert OLE Custom Controls dialog appears.
  2. Choose and Click the MetaDraw Control in the Select a Custom Control list.
    The control appears on the form or report.
Getting and Setting properties in Design View

Use the right mouse button to click the control, and then point to the MetaDraw Control Object command, and then click Properties to open the MetaDraw control property sheet.

You can also set properties for a MetaDraw control in the Microsoft Access property sheet.

Handling Events

Use the right mouse button to click the control, then point to the Build Event command, and add code to the event you want to handle. Note that not all events are shown in the Access properties window. Instead you can open up the code window, select the MetaDraw control from Control list on the top right of the code window and select the event you want from Event list on the top left of the code window.

Limitations

Drag and Drop – Microsoft Access does not support Standard Drag/Drop operations from one ActiveX control to another. The following MetaDraw properties and events are therefore not supported within Access: Drag Method, DragDrop Event, DragOver Event.

OLE DragDrop may be used to support dragging between MetaDraw and other controls.

Distributing Access Applications

Access projects are typically distributed as MDB files.

Unfortunately when running an MDB file Access always reports itself to the ActiveX control as running in Design Time mode. End-Users opening MDB projects therefore will require individual MetaDraw licenses.

In order to avoid the need for end-users to purchase MetaDraw licenses, you must distribute your Access application as an Access MDE file rather than the standard MDB files.


Using MetaDraw in Visual FoxPro

Before using MetaDraw OCX with Visual FoxPro you should read the chapter:

  • "Adding OLE" Chapter 18, in the FoxPro Developer's Guide

To add the MetaDraw Control to a form:

  1. In the Form Designer, add an OLE Container control to your form. The Insert Object dialog box appears.
  2. In the Insert Object dialog box, select Insert Control.
  3. Choose the MetaDraw Control from the Control Type list. If the MetaDraw Control doesn't appear in this list, you can add it to the list by choosing the Add Control button.

To quick access to the MetaDraw Control you can insert it to the Form Controls toolbox:

  1. Choose the Options.. command from the Tools Menu. The Options dialog box appears.
  2. In the Options dialog box select Controls tab.
  3. Select OLE Controls radio button and check the MetaDraw Control in the Selected list box. The MetaDraw's icon should appear on the Form Controls toolbox.
Design Time Properties Settings

In the Design Properties window you may not see several MetaDraw's properties. To set them use the MetaDraw Property Page. Just click the right mouse button on the control you want to change properties and choose the Properties menu command.

Run Time Property Settings

FoxPro is picky about the use of certain property or event names and may generate an error as a result. For example FoxPro has it's own internal AddObject method which would conflict with a similarly named method of a control such as MetaDraw. The solution is to use the special "Object" keyword.

Instead of
Control.Property
or Control.Method

Write
Control.Object.PropertyName
Control.Object.Method

Example:

MetaDraw.Object.AddObject  OT_RECTANGLE, 100,100,150,200
Events

There is a special switch in FoxPro which can affect the processing of events by ActiveX controls. One Symptom of problems is if some event is not being triggered.

For best performance use

_VFP.AUTOYEILD = .false.

This is an extract from the VFP help system

"The AutoYield property should be set to false (.F.) when a form contains an ActiveX control. Setting AutoYield to false (.F.) prevents events for an ActiveX control from executing between lines of user program code. For example, if AutoYield is set to true (.T.), clicking an ActiveX control while user program code is executing may cause an event for the ActiveX control to execute, ignoring the user program code for the event, producing undesirable or unpredictable results."

Limitations

MetaDraw is not supported in FoxPro 5

No Child Controls

FoxPro apparently has a bug and can not correctly support SimpleFrame controls. As a result SimpleFrame controls may not be properly scrolled and refreshed.

To avoid scrolling and refreshing problems due to the FoxPro error in handling Simple Frames, Simple Frame support must be turned off in MetaDraw. Set the flag PICOPT_FOXPROFORM in the MetaDraw PictureOptions property

MetaDraw.PictureOptions = MetaDraw.PictureOptions _
                   Or   PICOPT_FOXPROFORM

This limitation means that it is not possible to have embedded controls within MetaDraw when working in the FoxPro programming environment.

ObjTags

FoxPro does not support array properties with Strings as subscripts to the array. It is therefore not possible to directly use the ObjTags property. It is still possible to assign a value using the ObjTag property, and if multiple ObjectTags need to be defined it is possible to assign a value using ObjTag ( same as ObjTags with an empty string tag name) and then reset the Tag name using the ObjTagsName array. For example:

MdrawPro1.AddObject OT_RECTANGLE,100,100,200,200
MDrawPro1.ObjTag = "Desk"                 ' assign a tag value
MDrawPro1.ObjTagsname(0)= "What Is It"    ' change the tag name
MDrawPro1.ObjTag = "$344.00"              ' assign a new tag value
MDrawPro1.ObjTagsName(0) = "Price"        ' change the tag name

At this point there are now two tags assigned to the object which may be retrieved with the ObjTagsValue array property.


Using MetaDraw on a Web Page ( HTML)

MetaDraw looks great on a Web page. It's quick and easy to use MetaDraw to show hotspots on a Web site or to allow end-user annotation over the web.

Take a look at the Internet sample included with our installation kit. The main INDEX.HTM file sets up two Frames, one holding MetaDraw as a table of contents on the right (presented with MDR_IDX.HTM), and the second with the referenced HTML page to which various MetaDraw elements may point.

How to Add MetaDraw 3 to a Web Page:

It's really simple to add MetaDraw 3 to a web page. There is absolutely no need for any VBScript or Java code. The procedure is simple:

1. Create a MetaDraw MDR data file containing the initial image to be displayed in MetaDraw. An MDR file may be created using the HSEditor utility included with MetaDraw, or within an application of your own creation using the SaveData method. The MDR file must be created on a machine which is licensed for development use (License information will be automatically included in the MDR file).

2. Add the special <Object> HTML tag to your HTML page where would like MetaDraw to be shown.

<OBJECT ID="MetaDraw1" WIDTH=100% HEIGHT=100%
    CLASSID="CLSID: 644D8000-3033-A583-AD61-00403333EC93"
    CODEBASE= "www.yourserver.com/MetaDraw3.Cab#Version= 3,0,0,8"
    DATA="www.yourserver.com/MDR_DATA.MDR">
</OBJECT>

The Data attribute in the OBJECT tag must reference the MDR file used to initialize MetaDraw on your web page Without the MDR file your users will see a license warning. The MDR file may however be initialized as an empty picture.

The CODEBASE attribute in the OBJECT tag refers to the CAB file containing MDRAW30.OCX. A signed cab file has been included with the MetaDraw installation kit – you can copy this to your server.

3. If desired you can use VB Script or Java Script to manipulate MetaDraw just as you would if MetaDraw was used within a standard EXE application.

4. Remember MetaDraw can read new images from a URL using either HTTP or FTP protocols – just specify the full URL path as the first parameter in the LoadPicture method. MetaDraw automatically determines which protocol to use when loading a file (by http:// or ftp:// prefixes specified in URL). See LoadPicture method description for further information.

Notes: MetaDraw (and other ActiveX controls) can only be used on Web pages displayed within Microsoft Internet Explorer running on Intel compatible computers under Microsoft Windows.


The MetaDraw Picture

The MetaDraw control displays and operates on an image specified by the Picture property. All operations for creating, deleting, and changing objects are applied only to this picture (Main Picture) or elements within this picture (as pointed to by the .Current property).

This picture may be determined at design time either by specifying the picture's coordinates properties (to create an empty picture of some size) or by assigning a picture to the Picture property. The picture may also be specified at run-time by creating a new picture, or by loading or modifying an existing picture


Image and Control Size

Position and Size of the Control Window

Image Size – Original Unzoomed Size

Image On-Screen Presentation – Size and Position of the Image

Image Print / Export Size


Position and Size of the Control Window

There are three pairs of properties specifying the size and position of the control and it's client area.

Left, Top
Width , Height
ClientWidth, ClientHeight

The Left/Top and Width/Height properties determine the position and the size of the control inside its container. The ClientWidth/ClientHeight properties return the actual size of the MetaDraw's client area (without borders and /or scroll bars). ClientWidth and ClientHeight properties have an optional parameter to allow retrieving the size of the client area with or without the scroll bars.

Note that the size of the image held by MetaDraw is not constrained by the size of the client area. The image may be larger or smaller than the client area of the control.


Image Size - Original Unzoomed Size

Image Size – Original Unzoomed Size

Original Size - Base Display Dimensions

The properties OrigWidth and OrigHeight set the Original size assumed to be "normal" ( 1:1 zoom) for picture display or printing. This information is included within images saved by MetaDraw and will be used by most applications to determine how to handle the image. The original size is measured in units specified by the container's scaling mode.

Note that the size at which an image is displayed or printed is not limited by the Original Image Size. The image may be Zoomed for either on-screen, or printed display.

Also note that the image size is independent of the coordinate system used for adding image elements, and manipulating the image.


Image On-Screen Presentation - Size and Position of the Image

Image On-Screen Presentation – Size and Position of the Image

The On-Screen presentation size and position of the image is controlled by the following properties:

PicXOfs, PicYOfs
PicXSize, PicYSize
ZoomFactor , AutoScale

Display Size - Zoom Dimensions

The display size properties PicXSize and PicYSize specify the On-Screen Display size of the image. These properties are measured in the units specified by the scale mode of the parent container in which MetaDraw control is placed.

To stretch or shrink the image, set the ZoomFactor property ( preferred ), or set the PicXSize and PicYSize to a multiple of OrigWidth and OrigHeight. Setting the ZoomFactor property automatically sets both PicXSize and PicYSize to the same multiple of OrigWidth and OrigHeight, preserving the aspect ratio of the image. The AutoScale property may also be used to automatically scale the image, thereby setting the Zoom, PicXSize and PicYSize properties.

Note that while it is possible to zoom the image by different ratios in X and Y direction (by directly setting PicXSize and PicYSize to different multiples of OrigWidth and OrigHeight, or by setting the AutoScale property to SCALE_RESIZE) this can result in the appearance of certain distortions or misalignments – especially with regard to Text. It is therefore recommended to maintain the ratio PicXSize/ OrigWidth and PicYSize / OrigHeight, and to control zooming by setting either the Zoomfactor property, or by setting AutoScale to SCALE_ORIG, or SCALE_FIT.

Changing the displayed size of the image has no effect upon the underlying data or the internal coordinate system.

Offsets

The offset properties (PicXOfs, PicYOfs) determine the position of the picture inside the MetaDraw control box. When PicXOfs, PicYOfs are zero the left-upper corner of the picture will be placed in the left-upper corner of the client area. PicXOfs, PicYOfs and PicXSize, PicYSize are independent.


Image Print / Export Size

MetaDraw also support control over the printed size of an image. The printed size of an image is controlled by the following properties:

ExportLeft, ExportTop,
ExportHeight, ExportWidth , ExportOptions


MetaDraw Coordinate System

Logical (or picture) coordinates

MetaDraw supports an internal Logical Coordinate System which is independent of either the original (unzoomed) or the on-screen display size of the image. This coordinate system is used when adding new drawing objects (as with the AddObject method), when reading the position of an object, or when moving an object.

The coordinate system is specified by the following properties:

PicLeft | specifies the minimum X ( Horizontal ) coordinate, referencing the Left Edge of the image.
PicTop | specifies the minimum Y ( Vertical ) coordinate, referencing the Top Edge of the image.
PicWidth | specifies the range of the X axis, horizontal extent of the coordinate system
PicHeight | specifies the range of the Y axis, vertical extent of the coordinate system

All object coordinates within a MetaDraw picture are specified in logical units ranging from (PicLeft, PicTop) to (PicLeft+PicWidth, PicTop+PicHeight). Coordinates always increase from Left to Right and from Top to Bottom.

When loading an image the coordinate system will be determined by the image being loaded.

When creating a new image, the default coordinate system ranges from ( 0,0 ) to ( 1000, 1000 ) but PicTop, PicLeft, PicHeight and PicWidth may be chosen for convenience – generally to establish a coordinate system which is either easy to use ( say from 0 to 1000) or which easily translates to some real-world corresponding units ( such that each unit represents a degree of Latitude, a tenth of an inch, or a degree Centigrade, etc.)

Coordinate System and Image Resolution:

In addition to defining the extent of the coordinate system, the PicWidth and PicHeight properties also determine the picture resolution. Assigning too low a value to PicWidth and/or PicHeight limits the precision with which graphic elements ( lines etc) may be placed or drawn, and may result in blockier images. For most applications a value between 1000 and 10,000 is quite suitable. The values of PicWidth and PicHeight are usually chosen for convenience.

The following images show the effect of changing resolution using PicWidth and PicHeight.

Note - the standard for Windows MetaFile Format only supports resolution settings up to 32,767 – higher values should not be used for PicWidth and PicHeight if the image is to be exported to WMF format.

Note – it is important to use the same coordinate resolution in the X and Y directions – The rations, PicWidth / OrigWidth and PicHeight/OrigHeight should be maintained as equal values.

The Logical Coordinate System settings HAVE NO EFFECT upon picture placement or size and DO NOT depend upon the device context.

Note that the ClientToLogicX and ClientToLogicY properties may be used to convert between a pixel based X, Y coordinate location within the client rectangle, and logical coordinates within the overall image.

For more information see Initializing a New Image / Setting Active Drawing Size


Picture Organization - Graphic Objects and Containers

An Image is Build from Graphic Objects

Object Handles - Accessing the Current Object(s)

Containers/ Object Groups

Open container

Layering Order of Objects


An Image is Build from Graphic Objects

The image held in the MetaDraw control consists of a set of graphical "objects or "elements" such as lines, rectangles, polygons, texts, bitmaps, and containers (object groups). Each graphic object is distinctly maintained and manipulated by MetaDraw control within the context of the overall image. It is therefore possible to add, delete, move, resize, rotate, and change various characteristics of each object independently of the rest of the image.

MetaDraw properties which are used to modify objects in the picture act upon the object(s) referenced by the .Current property. This property can be set to point to a specific objects, or to a group of objects (for instance all selected objects). For more details refer to the section "Object Handles - Accessing the Current Object(s)" later in this chapter.

Multiple Objects can be "Grouped" into "Containers" to act as a single object. For further details see Layering Order of Objects later in this chapter.

Objects are layered – objects can be moved in front or behind other objects. For further details see Containers/ Object Groups later in this chapter.


Object Handles - Accessing the Current Object(s)

Each object within an image is automatically assigned an object handle as it is created ( drawn or added to the image) or as the image is being loaded. The handle, a long integer value, uniquely identifies that object to MetaDraw.

The "Current Object" is the object ( or objects) MetaDraw's Internal Pointer points to, it is the object upon which actions are taken, or for which attributes may be read by most MetaDraw properties. The Current property points to the Current Object within the overall image by specifying an object handle identifying the object.

Any actions taken to modify object attributes ( line colors, line thickness, text, object position, etc) are applied to the Current Object ( the object or set of objects pointed to by the Current property). This is NOT necessarily the same as the currently Selected object.

It is possible to read the Current property for an object immediately after it is created (for instance by the AddObject method, after setting the Action property, after setting the ObjNumber property), or during the Change event when an end-user is adding items with the mouse. This value may be saved and then used at a later time to refer to the object.

Note that in MetaDraw the most convenient way to identify an object is to assign an Object Tag using the ObjTags property to the item as it is created, and then to use the FindObjectTags method which will automatically set the Current property to the desired item according to its tag.

Certain reserved handles have been defined to allow easy access to frequently used objects. Simply assign one of the following constants to the Current property.

Constant | Value | Description
OBJ_CONTAINER | 1 | Specifies all objects in the current open container.
OBJ_SELECTED | 2 | Specifies all selected objects.
OBJ_SEL_ATTR 3 Specifies all selected objects and global MetaDraw object's attributes for getting/setting attribute operations.
  • This setting is valid only for getting or setting attributes of an object (like LineColor, Text, BackStyle, DrawMode).
  • Reading an attribute property while the Current property is set to OBJ_SEL_ATTR returns the attribute value of the selected objects only if this is the same for all selected objects, otherwise the value of the global object's attribute is returned.
OBJ_DEFAULT 4 Specifies global MetaDraw object's attributes for getting/setting operations.
  • This setting is valid only for getting or setting attributes of an object (like LineColor, FontSize, BackStyle, DrawMode).
OBJ_CURR_ATTR | 4 | Old constant name – maintained for backward compatibility
OBJ_CONT_MAIN 5 Specifies the Main Container.
  • If you set the Current property to OBJ_CONT_MAIN and then read it back, the resulting value is the handle of Main Container.


Containers/ Object Groups

Several objects can be grouped into a "container" ( also referred to as a "group"). The container can then be manipulated ( moved, resized, rotated, color changed, or otherwise modified) as a single object. The complete image that held by MetaDraw is itself a container holding all the graphical elements within the picture.

Selected Objects may be grouped, and grouped Containers may be ungrouped using the Action property. Containers may be opened or closed using the ObjOpened property. Opening a container allows action on the individual elements within the container.


Open container

A container (grouping of objects) can be put into another container resulting in nested levels. The Editing of MetaDraw objects can however be performed on only one container (one level) at a time. The Open Container is the container (group) where editing operations are allowed. New objects will also be added to this open container.


Layering Order of Objects

All objects inside a MetaDraw container are held in an internally maintained list that determines which objects are in front of others. As objects are added to a MetaDraw image they are appended to the end of that list. When the picture is repainted, it is drawn starting with the bottommost object, up to topmost one. Therefore, objects that are added later will generally be drawn on top of ( in front of) previously drawn objects. An object's position in the list (and thereby the visible layering of the objects) can be modified by appropriate setting of the Action property. (See "Changing the layering order of objects").

Within a container, an object's position within the list may be read with the ObjNumber property.


The Control Area vs The Drawing Area

As noted above, the picture or Active Drawing Area held within MetaDraw may be smaller than the control itself. The on-screen picture size is specified by the PicXSize and PicYSize properties and the client area of the control by the ClientWidth and ClientHeight properties. If PicXSize is smaller than Width, or PicYSize is smaller than ClientHeight, then the background of the control will be seen beyond the drawing area. This Background will generally be shown with a solid color as specified by the PicBorderColor property, while the background color of the image is generally specified by the PicBackColor property. These backgrounds may be further modified depending on the BackPicture, BackPictureAlignment, GradientStyle, and TransparentBackground properties.

End-Users can not draw outside of the ActiveDrawing area, regardless of the size of the control.


File Formats

MetaDraw supports loading and saving both Raster and Vector Format images.

Format Name | Extension | Type | Comments
Bitmaps | .BMP, .RLE, .DIB | Raster |
Icon | .ICO | Raster |
JPEG | .JPG | Raster - Compressed |
PNG | .PNG | Raster - Compressed |
Metafile | .WMF | Vector |
Enhanced metafile | .EMF | Vector |
MetaDraw picture | .MDP | Vector |
MetaDraw data | .MDR | Vector | MDR format actually is more than an image format; it contains the complete state of the MetaDraw control and properties, and is generally used for setting up defaults especially on Web pages. This format is accessed only with the SaveData and LoadData methods.
AutoCAD DXF | .DXF | Vector | DXF format support for MetaDraw requires DXF Support License Option. (See Appendix "DXF Support" for details)
TIFF and CAL |  | Raster | TIFF and CAL images are supported only as background images in MetaDraw and such support requires purchase of the optional ClearEdge module.
GIF | .GIF | Raster - Compressed | GIF formatted images may be read under Visual Basic using the Visual Basic LoadPicture functions to assign to MetaDraw's Picture property.

Note: Other file formats may be supported through use of MetaDraw in conjunction with other third party controls. Bennet-Tec may also be contracted to develop support for other image filters on a contract basis.

Note that the MetaDraw internal MDP format is generally preferred for maximum speed, and to preserve the complete set of features of independent objects making up a drawing / diagram within MetaDraw.

More:

Raster Vs Vector Format Images


Raster Vs Vector Format Images

Raster images are images in which the color and intensity of each location within an image is represented by a data point.

Vector images are images where distinct entities such as lines, shapes, text, and are maintained within an image and represented by their locations and characteristics (example Line start and end points, line thickness, line style, color…).

There are several Advantages of Vector Format Images:

  • For most drawing and Diagramming applications, Vector images may require only a tiny fraction of the disk space/memory required for Raster images,
  • Independent elements within an vector image remain distinct when saved and reloaded. Annotations can be recognized distinct from the original image, even keeping track of annotations created by different end-users. Lines drawn in one session may be later moved in another session. Text added in one session can be recognized and modified in a later session, etc.
  • MetaDraw can load and save both Vector and Raster images.

Conversion from Vector to Raster images is quite simple with MetaDraw. The image is simply saved to the desired Raster Format.

Embedding Raster Images within a Vector format is also straight forward with MetaDraw. A Raster image can be loaded in its native format and simply resaved in one of the supported vector formats, or merged with other images, shapes and text and then saved.

Conversion from Raster to Vector may in some cases be desirable in order to reduce file size, aid in manipulation of the image, aid in recognition of image components. This process, "Vectorization", may be performed automatically by MetaDraw for users of the Vectorization License Option. MetaDraw's Vectorization algorithms are best suited to vectorizing what we refer to as "color maps" – images with regions of color representing distinct graphic elements. With the Vectorization license option MetaDraw can convert the colored regions in such images into distinct polygon shape objects.


Programming Techniques

The MetaDraw control displays and operates on an image or canvas specified by the Picture property. All operations for creating, deleting, and changing objects are applied only to this picture (Main Picture) or elements within this picture (as pointed to by the .Current property).

This picture can be created/initialized, loaded with some existing image, drawn upon by the end-user or by the program code, assigned hotspots, rotated, printed, saved, and more. This section will describe some of the basic techniques used in working with MetaDraw.


Loading an Existing Picture

MetaDraw's picture may be set at design time or run-time by assigning a picture to the Picture property.

  • DESIGN TIME PICTURE SETTING

MetaDraw's Picture property can be set directly from the Design Environment's Property List. Alternatively right-click on MetaDraw at design time and set the Picture property in MetaDraw's own Design Time property dialog.

  • DIRECTLY SETTING THE PICTURE PROPERTY

At run time, you can also initialize the picture by directly assigning a picture to the Picture property by reference to a picture held in another control.

MDraw.Picture = PictureBox.Picture

When directly setting the Picture property the picture's size and coordinates will be set according to the picture loaded.

Visual Basic Note: Visual Basic developers may also use Visual Basic's own built-in the LoadPicture function:

MDraw.Picture = LoadPicture("SOMEPIC.WMF")

Generally, MetaDraw's own LoadPicture method is faster than Visual Basic's LoadPicture function; however users of Visual Basic's function can read GIF images which are not directly supported by MetaDraw's LoadPicture method.

  • COPYINNG A PICTURE FROM ANOTHER INSTANCE OF METADRAW

    The Picture property of MetaDraw is a stock property which can not hold all the details which may be represented within a MetaDraw image. Using the MDPicture property to transfer an image from one MetaDraw control to another retains the full details.

    MetaDraw1.MDPicture = MetaDraw2.MDPicture
  • LOADING PICTURES FROM A DATA SOURCE ( File, URL, Database, Binary Array)

MetaDraw's LoadPicture method provides flexible support for loading a variety of image formats from a variety of possible sources.

The LoadPicture method takes 3 parameters – the first, Source determines from where MetaDraw loads the image.

The image source can be:

  • a FileName or Web URL
  • a VB or Windows File Handle
  • a database field object (DAO field, ADO field, or RDO column)
  • a Byte Arry – a byte array variable which contains picture data

The 2nd parameter, PicDst, specifies which MetaDraw property (Picture, PictureImage or PictureClip) will receive the loaded picture. To specify the main picture – the picture seen within MetaDraw control – this PicDst should be set to the constant PIC_PICTURE (value 0)

The 3rd (last) parameter, PicType, is optional. If the PicType parameter is zero, the function will try to recognize the type of the picture automatically. Otherwise MetaDraw will try to interpret the datasource according to the picture type specified by PicType.

Note: Attempting to load a picture from a file which does not exist, can not be opened, or which does not contain an image type recognized by MetaDraw will result in a trappable error condition.

Image Formats:

MetaDraw supports the following picture formats: bitmap (.BMP, .RLE, .DIB), icon (.ICO), JPeg (.JPG), PNG (PNG), metafile (.WMF), enhanced metafile (.EMF), MetaDraw internal format (.MDP).

Reading from GIF formatted files may be accomplished under Visual Basic using the Visual Basic LoadPicture functions

DXF format support for MetaDraw is available as a separate licensing option from Bennet-Tec.

Background Image support for TIF and CAL format may be added with the optional ClearEdge module.

Note: Other file formats may be supported through use of MetaDraw in conjunction with other third party controls (such as DataTechniques ImageMan). Bennet-Tec may also be contracted to develop support for other image filters on a contract basis.

  • INITIALIZING IMAGE FROM THE CLIPBOARD

The example below shows how you can create a new picture, by copying from the clipboard:

If Clipboard.GetFormat(3) Then
    Index% = 3    ' There is a metafile in the Clipboard
ElseIF Clipboard.GetFormat(8) Then
    Index% = 8    ' There is a DIB in the Clipboard
ElseIf Clipboard.GetFormat(2) Then
    Index% = 2    ' The Clipboard has a Bitmap
Else
    Index% = 0    ' No valid picture in the Clipboard
End If
If Index% Then MDraw.Picture = Clipboard.GetData(Index%)
  • COPYING DATA FROM MetaDraw's "temporary" image (PictureImage property).

You can initialize the MetaDraw's picture with an image held in the PictureImage property. To do this, assign ACT_IMAGEPICTURE or ACT_IMAGESWAP to the Action property.

MDraw.Action = ACT_IMAGEPICTURE    ' or
MDraw.Action = ACT_IMAGESWAP
Note The PictureImage property must be set with some valid picture before performing this action. The PictureImage property may be set directly (as with the Picture property), or may be set with the MetaDraw LoadPicture method specifying constant PIC_PICTUREIMAGE as the nPicDest parameter.


Initializing a New Image / Setting Active Drawing Size

You will generally want to start by initializing MetaDraw either by loading an existing image, or by creating a new blank picture upon which to build / draw an image or diagram. (alternatively you may wish to load an initial picture rather than starting with a blank canvas – in that case see the section Loading an Existing Picture

As described earlier, the image held in MetaDraw has independent attributes of Size and Coordinate System. (The Original size is as specified by OrigWidth and OrigHeight, The display size is as specified by the ZoomFactor or by PicXSize and PicYSize properties, and the coordinate system is as specified by PicLeft, PicTop, PicWidth and PicHeight properties.

When creating a new image / diagram you will want to identify some "original size" – that is the unzoomed or natural size of the image. For example the image should be 8 inches by 11 inches in an unzoomed state. This may be larger or smaller than the MetaDraw window itself and may later be zoomed in or out for the desired on-screen image presentation.

You will also want to define a convenient "logical coordinate system", setting up the units used for placement of image elements. The logical coordinate system is independent of the physical image size but should be chosen to have the same ratio in height and width as the image dimensions.

To initialize MetaDraw with a new empty picture at run time, execute these steps:

  1. Destroy the old picture by resetting PicHeight or PicWidth to zero:
    MDraw.PicWidth = 0
    or MDraw.PicHeight = 0
  2. Set the properties required to specify the logical coordinate system (PicLeft, PicTop and PicWidth, PicHeight), the original Unzoomed size (OrigWidth and OrigHeight), and the Zoom (.Zoom for the picture being created.
  3. Create the new empty picture with the specified logical coordinates and original size by calling the Clear method:
    MDraw.Clear

Note – It is IMPORTANT for best presentation to maintain the same coordinate resolution in X and Y directions – Original Image Size and Coordinate System extent should be set such that PicWidth / PicHeight = OrigWidth / OrigHeight. For convenience, we strongly recommended to define two global constants and to set the values PicWidth, PicHeight, OrigWidth and OrigHeight based on these constants.

EXAMPLES:

The following examples assume that the ScaleMode of the container / Form, upon which MetaDraw is placed, is set to Twips)

Example 1 –Simple Image and Coordinate Systems

'--------------------
' Define two Global constants
' These constants should be defined to fit the application
'  - the first constant is used as a reference to set
'    the original (unzoomed) image size – the workspace area
'    as defined by OrigWidth and OrigHeight
'  - the second constant is used to set up a convenient
'    logical coordinate system as defined by PicWidth and PicHeight
     TwipsPerInch = 1440          ' Windows standard
     LogicalUnitsPerInch = 1000   ' gives 1000 logical units per inch
'           < OR >
     TwipsPerCM = 567           ' Windows standard
     LogicalUnitsPerCM = 1000   ' gives 1000 logical units per cm
'           < OR >
     TwipsPerCM = 567           ' Windows standard
     LogicalUnitsPerCM = 567    ' internal units now equal twips
'--------------------
' Define size of the drawing area - the canvas
     MetaDraw.OrigWidth = DesiredWidthInInches * TwipsPerInch
     MetaDraw.OrigHeight = DesiredHeightInInches * TwipsPerInch
' Define the internal coordinate system
     MetaDraw.PicLeft = 0
     MetaDraw.PicTop  = 0
     MetaDraw.PicWidth  = DesiredWidthInInches  * LogicalUnitsPerInch
     MetaDraw.PicHeight = DesiredHeightInInches * LogicalUnitsPerInch
' Lastly set up actual on-screen viewable size.
' This may be done using the ZoomFactor property,
'      the PicXSize and PicYSize properties,
'      or using the AutoScale property
     MetaDraw.ZoomFactor = 1

Example 2 – A Scaled Image and Coordinate System

Alternatively you may want to start with an image size at some scale relative to a larger ( or smaller) real world dimension, for instance in constructing a map of some geographic area of say 10 miles by 20 miles, you may wish to represent this on a scale of 1 inch = 20 mile. Then the coordinate system should be specified for convenience and to establish a desired resolution.

ScaleMilesPerInch = 20         ' MilesPerInch
TwipsPerScaleMile = 1440 * ScaleMilesPerInch
LogicalUnitsPerScaleMile = 5267    'internal units represent feet.
.OrigWidth  = RealWorldWidthInMiles * TwipsPerScaleMile
.OrigHeight = RealWorldDepthInMiles * TwipsPerScaleMile
.PicWidth   = RealWorldWidthInMiles * LogicalUnitsPerScaleMile
.PicHeight  = RealWorldDepthInMiles * LogicalUnitsPerScaleMile

Note that the scaling used here to get an Original Width and Height defines the Unzoomed size of the image, and still leaves one free to set the on-screen display size using the ZoomFactor, PicXSize, PicYSize or AutoScale properties.

Example 3 –Representing Longitude and Latitude

Or let's set up a Latitude and Longitude system centered at the equator at 0 Longitude.
We'll assume we want each logical unit to represent 1 minute of arc (60 minutes per degree), and the logical coordinate system might range from Longitude , Latitude (-180 ,-90) to (180, 90) and we'd like each degree of arc to be displayed as 1 mm (unzoomed).

TwipsPerDegreeOfArc        = 56.7 'Windows Standard 1 mm = 56.7 twips
LogicalUnitsPerDegreeOfArc = 60   '1 unit = 1 minute, 60 min/degree
.PicLeft   = -180 * LogicalUnitsPerMinuteOfArc
.PicWidth  =  360 * LogicalUnitsPerMinuteOfArc   ( -180 to 180)
.PicTop    =  -90 * LogicalUnitsPerMinuteOfArc
.PicHeight =  180 * LogicalUnitsPerMinuteOfArc   ( -90 to 90)
.OrigWidth  = 360 * TwipsPerDegreeOfArc
.OrigHeight = 180 * TwipsPerDegreeOfArc

Note the picture size can also be set at Design Time either directly in the Design Time Properties Windows of the programming environment, or by right clicking on MetaDraw at design time and selecting Properties to pull up the MetaDraw design time properties dialog.

Example 3 –Representing Longitude and Latitude

Finally let's set up a picture where we'd like the picture size to simply be set by the size of the MetaDraw control as it has been placed on the form at design time.

Const TwipsPerInch = 1440     '  windows standard
                              ' you might want to define TwipsPerCm
                              ' or other convenient units
' Set up size
With MetaDraw
    .Clear
    ' size the picture without Zoom to fill the MetaDraw control
    .ScrollBars =BAR_NONE
    .OrigWidth = .ClientWidth
    .OrigHeight = .ClientHeight

    ' Set up Coordinate System ( by default this is 1000 x 1000)
    ' for best results make proportional to image dimensions
    Const UnitsPerInch = 100   '( global constant - choose a value
                               ' convenient for your needs)
    .PicWidth = OrigWidth  / TwipsPerInch * UnitsPerInch
    .PicHeight = OrigHeight / TwipsPerInch * UnitsPerInch
    .ZoomFactor = 1  ' don't zoom image
End With

Following these steps, a new empty picture will be created. You can now programmatically create and edit new objects using AddObject methods, or you can set the EditMode property to allow the end-user to draw new objects directly by dragging the mouse.


Saving Pictures

Saving pictures from MetaDraw is very similar to loading operations.

MetaDraw has own methods to save its pictures. You can save a picture to a file ( by name or open file handle), a database field object or a binary data array.

MetaDRAW.SavePicture (Target As Variant, nPicSource, [nPicType])

The nPicType parameter is used to specify a file format (BMP,WMF, JPG, PNG, DXF, EMF, ICO,MDP) for saving. ( Saving in DXF format requires DXF Export Support License).

The Target parameter identifies where the picture should be stored

  • a FileName
  • a Visual Basic or Windows File Handle
  • a database field object (DAO field, ADO field, or RDO column)
  • a Byte Arry – a byte array variable which contains picture data

The 2nd parameter, nPicSource, specifies which MetaDraw picture property is being saved. Set this to the constant PIC_PICTURE (value = 0), to save the main image. Values of PIC_PICTURECLIP may be used to save the portion of the image returned by the PictureClip property, and PIC_PICTUREIMAGE may be used to save the picture held in the PictureImage property.

The Picture property of MetaDraw may also be read directly.

Visual Basic programmers can also use their familiar SavePicture statement to save images to a file. Just set the PictureType property to specify the picture format you want to save, and call the Visual Basic SavePicture statement passing it the Picture property and the file name. The VB SavePicture statement may also be used to save the image returned by the PictureClip property or held in the PictureImage property. MetaDraw's own internal SavePicture method is generally faster than VB's method. MetaDraw's SavePicture method also preserves the original color depth of the image where as Visual Basic's SavePicture statement changes the image to the color depth of the current system settings for Windows.

Note that the background image in MetaDraw will NOT normally be included in the image when reading the picture property, or saving a picture with the SavePicture method. To include the background image make sure to specify the EXOPT_BACKGROUND flag in the ExportOptions property before saving or before reading the Picture property.

MDraw.ExportOptions = MDraw.ExportOptions OR EXOPT_BACKGROUND
MDraw.SavePicture  "filelname", Pic_Picture, Pictype_Bitmap


Zooming and Scrolling pictures

MetaDraw offers flexible and easy support for both Zooming and Scrolling of images.

End-Uses may directly zoom or scroll the picture:

  1. Zoom or Scroll using the MouseWheel
    The ScrollMouse property determines how MetaDraw reacts to user action upon the MouseWheel. In addition the MouseWheel event may be processed to provide customized support of the mouse wheel. Mouse wheel support is provided only under Win 98, ME, 2000, NT4, and XP. MouseWheel support is not provided under Win 95.
  2. Scroll using the scrollbars
    The ScrollBars property determines whether MetaDraw will display scrollbars all the time, never or only as needed.
  3. Scroll by dragging the mouse within the image (with the Right mouse button).
    Press and hold the RIGHT mouse button, drag the picture in the control, then release the button. The cursor [image] appears while you are dragging the picture. This feature can be disabled by setting the ScrollMouse property.
  4. Scroll using the keyboard.
    When MetaDraw has the focus the cursor keys scroll the picture horizontally or vertically. This feature may be disabled by setting the ScrollKeyboard property to False.
  5. Zoom and Scroll by selecting an area with the mouse.
    With the EditMode property set to ED_ZOOM, the user can draw a zoom rectangle and MetaDraw will automatically scroll and Zoom to that rectangle. Simply Clicking with the mouse while in this edit mode will also Zoom the image. In this edit mode, the image may be UnZoomed by holding down the Control Key while using the mouse.

When EFLG_DONTSCROLL is cleared (not set) in EditFlags property MetaDraw will scroll the picture when the user drags an object beyond the client window.

Scrolling by code

The offset properties (PicXOfs, PicYOfs) are used to determine the position of the picture inside the MetaDraw control box. When PicXOfs, PicYOfs are zero the left-upper corner of the picture will be placed in the left-upper corner of the client area. PicXOfs, PicYOfs and PicXSize, PicYSize are independent.

Zooming by Code

Zooming is most easily accomplished with the ZoomFactor property. This sets the visible size of the image to a multiple of the OrigWidth and OrigHeight properties.

MDraw. ZoomFactor = 0.60  ' zooms the image to 60 percent of
                          ' it's Original size a specified by
                          ' OrigWidth and OrigHeight properties

The PicXSize, PicYSize properties determine the visible size of the picture, in units specified by the ScaleUnits property parent control's scaling mode (twips by default). To ZOOM or SHRINK the image to a specific size, the PicXSize and PicYSize properties may be set to some multiple of the OrigWidth and OrigHeight properties (the original size) or to other desired values (e.g. in twips or pixels):

MDraw.Redraw = False
MDraw.PicXSize = Zoom * MDraw.OrigWidth
MDraw.PicYSize = Zoom * MDraw.OrigHeight
MDraw.Redraw = True

MetaDraw images may also be automatically scaled using the AutoScale property. You can display the picture in its original size (SCALE_ORIG), fit it inside the MetaDraw box preserving its aspect ratio (SCALE_FIT), or scale it so that it will always cover the whole MetaDraw window (SCALE_RESIZE). The PicXSize and PicYSize property can only be set while the AutoScale property is set to SCALE_NONE.

Note: Stretching the image by different percentages along the two axis (horizontal and vertical) may result in some distortion - especially when if the image contains some text objects. For best presentation the original aspect ratio should be maintained – setting the ZoomFactor property, or setting AutoScale to Sale_Orig or Scale_Fit are therefore preferable in most cases to directly setting PicXSize and PicYSize, or setting AutoScale to Scale_Resize.

Note: To prevent the picture from "flashing" while changing the position or/and size, use the Redraw property. Set the Redraw property to False before changing the PicXOfs, PicYOfs and PicXSize, PicYSize properties. Then reset Redraw to True in order to redraw the picture with new size and position.

Scroll Event Notification

The Scroll event will occur after any changes in the picture's position or size, regardless of how they were changed. Also, the picture will be automatically updated after any changes of the PicXOfs, PicYOfs and PicXSize, PicYSize properties. You may prevent changing the PicXOfs, PicYOfs and PicXSize, PicYSize properties in the Scroll event. The following code prevents vertical scrolling while allowing user to scroll horizontally.

Sub MetaDraw_Scroll()
    MetaDraw.PicYOfs = 0
End Sub


Editing an Image

The MetaDraw control has several built-in tools for editing the picture. You can add new graphic elements, merge pictures, delete parts of the picture, move objects around or change their attributes (size, colors, etc.).

All editing operations are performed only on the picture specified by the Picture property. Also, you can edit only one part of the picture at a time (the currently open container - see the ObjOpened property).

More:

Adding to an Image

Setting Default Attributes

Selecting objects

Editing objects

Deleting objects

Grouping or ungrouping drawing objects

Rotating an object

Flipping an object

Changing the layering order of objects


Adding to an Image

The ability to annotate an image by adding new graphic objects (text, lines, rectangles, polygons, and even other complete images) is a basic MetaDraw feature.

Annotation/drawing may be done manually using the mouse under one of the special edit modes (see the EditMode property), or programmatically using the AddObject method.

Drawing with the Mouse

MetaDraw supports several edit modes for drawing/adding new objects using the mouse.

To create an object using the mouse, set the EditMode property (this may be done in a command button, or menu item). The mouse cursor's appearance will change for each mode (see table). Then, press the left mouse button and drag the mouse to draw the object. A new object will be added after the left mouse button is released. After the object has been added you may continue editing the object (for polyline/polygon and text objects).

After adding an object with the mouse, the Current property will contain the handle of the new object. The new object is NOT automatically selected and the prior selection status of existing objects is not changed.

Also after adding an object the Change event is fired. The change event is an excellent time to specify an object tag or to save the value of the Current property in order to identify that object at a later time.

The edit modes supported by MetaDraw include:

EditMode Constant | Value | Cursor | Action
ED_VIEW | 0 |  | View Only – no editing allowed
ED_LINE | 1 |  | Draw a line
ED_RECT | 2 |  | Draw a rectangle
ED_ROUND | 3 |  | Draw a rounded rectangle
ED_ELLIPSE | 4 |  | Draw an ellipse
ED_ARC | 5 |  | Draw an arc
ED_PIE | 6 |  | Draw a sector
ED_CHORD | 7 |  | Draw a chord
ED_POLYLINE | 8 |  | Draw a polyline
ED_POLYGON | 9 |  | Draw a polygon
ED_TEXT | 10 |  | Add a text object
ED_SELECT | 11 |  | In this mode the user can select, move and resize objects.
ED_IMAGE | 12 |  | Add an image
ED_ROTATE | 13 |  | In this mode the user can select, move, and rotate objects.
ED_BEZIER | 14 |  | Draw Bezier Curve
ED_DIMLINE | 22 |  | Add Dimension Lines
ED_LINKLINE | 23 |  | Add / Draw Link Lines between elements
ED_ZOOM | 24 |  | Zoom / Unzoom by clicking

Adding Text - If the EditMode property is ED_TEXT, dragging the mouse draws a line, which specifies the desired text size and rotation angle (if SHIFT key is held down) for text entry. A single mouse click will add a new text object with the current attributes (size and orientation). After the left mouse button is released an empty text object will be created and the cursor caret will appear, ready to accept characters from the keyboard. The end-user can now specify the text string for the new object. For Boxed or Mutli-Line styles the user may add a new line using the <CNTL> <ENTER> keyboard combination.

Adding an Image - In EditMode ED_ADDIMAGE, dragging the mouse determines a rectangular area into which the image specified by the PictureImage property is inserted.

Adding PolyLines/Polygons - When the EditMode property is ED_POLYLINE or ED_POLYGON, the end-user can drag the mouse to create freeform shapes.

The user interface – how MetaDraw interprets MouseClicks and dragging in these edit modes depends on the setting of the EFLG_POLYFREEHAND flag bit in the EditFlags property.

By default ( with this bit set), Click the left mouse button to indicate the initial vertex. Simply click again to add a new vertex joined to the previous by a straight line segment, or continue to hold down the left mouse button while dragging in order to draw freeform shapes (the mouse cursor will be changed according to drawing mode). Each click of the mouse adds another straight line segment. Double click the left mouse button or press the ENTER key (last vertex will be included) or the ESC key (last vertex will be removed) to complete the object

With the EFLG_POLYFREEHAND flag bit cleared, lifting the mouse completes the drawing of the shape - use <Shift> key to draw line sections of polygon

Adding Bezier Curves-When EditMode property is ED_BEZIER the initially drawn object will be made up of straight line segments.. (Holding down the SHIFT key will force the segments vertical or horizontal). If EFLG_POLYFREEHAND flag is set in EditFlags property you may add several segments of Bezier curves (on each left mouse button click) and the object is completed on a DoubleClick. If this flag is not set, only one segment will be added (editting is finished on mouse up).

It is then possible in ED_EDIT mode to double click on the Bezier object to open it and edit the curves. Or remaining in ED_BEZIER mode the object can be opened for editing by setting OBJ_OPENED = True. In this mode points may be added, moved, or removed. This is as done with Polylines and Polygons.

Adding Diagram Link Lines - When the EditMode property is ED_LINKLINE the end-user can click first on one object and then another to create a diagram link between the objects. Refer to "How to Create and Manipulate Diagram Links" for further information.

Keyboard Options While Drawing

During mouse dragging, you can hold down the following keys:

<SHIFT> - Equal Sided Objects / Angle of Text / Perpendicular Lines

The <SHIFT> key allows you to add an object with equal sides. Hold down this key if you want to create a circle or a square or prevent the change of an aspect ratio of image.

Holding down the <SHIFT> key also allows you to determine orientation of the text string (a rotation angle) (this feature is available only for TrueType fonts).

The <SHIFT> key may also be used to restrict Lines, PolyLines and Polygons to horizontal and vertical sections.

<CTRL> - Snap To Grid

During mouse dragging, you can hold down the CTRL key, which toggles Snap-to-Grid effect. The current mouse coordinates will be pulled into alignment with the nearest intersection of grid lines during the drawing of an object.

This can be used to draw most objects with the inverse of the GridAlign property current setting. For PolyLines and Polygons the CTRL key is always required regardless of GridAlign property setting in order to snap to grid points.

Programmatically Adding Objects - (Using the AddObject method)

Using the AddObject method you can add an object with one of the following types:

Object Description | Image | Constant
Line |  | OT_LINE
Rectangle |  | OT_RECTANGLE
Rectangle with rounded corners |  | OT_ROUNDRECT
Ellipse |  | OT_ELLIPSE
Arc |  | OT_ARC
Sector (pie slice) |  | OT_PIE
Chord |  | OT_CHORD
Polyline |  | OT_POLYLINE
Polygon (freeform) -initialized as line |  | OT_POLYGON
Text | 'abc' | OT_TEXT
Image |  | OT_IMAGE
Dimension Lines |  | OT_DIMLINE
Bezier Curves |  | OT_BEZIER
Polygon - Triangle shape |  | OT_TRIANGLE
Polygon - Diamond shape |  | OT_DIAMOND
Polygon - Hexagon shape** |  | OT_HEXAGON
Polygon - Pentagon shape** |  | OT_PENTAGON
Polygon - Octagon shape |  | OT_OCTAGON
Polygon - Star shape |  | OT_STAR

** Note: Adding Triangles, Diamons, Hexagons, Pentagons, Octagons, or Stars actually adds objects of type OT_POLYGON, once added they are treated as ordinary polygons. Reading the ObjType property will return OT_Polygon, not OT_Triangle, etc

Objects/graphic elements are added to a MetaDraw image by specifying the object type (from the list above) and it's size (based upon the bounding rectangle).

Syntax

MDraw.AddObject obj_type%, left&, top&, right&, bottom&

In each of the above methods/functions, the parameter ObjType is an integer specifying which type of graphic element (from the list above) to add. You can specify this parameter using one of the predefined constants (OT_xxxx, see table above).

The parameters left, top, right, and bottom specify the coordinates of the bounding rectangle determining the size of the added object. By default the coordinate system ranges from (0,0) to (1000, 1000). A different logical coordinate system may be specified using the PicLeft, PicTop, PicWidth and PicHeight properties.

Example:

' add a rectangle (Object type OT_RECTANGLE) bounded
' by left/top coordinate (100,100), and
' right/bottom coordinate (300,500)
MetaDraw.AddObject OT_RECTANGLE, 100, 100, 300, 500

There is also a method s – AddObjectDefault – that allows you to add an object with default coordinates. Its syntax is

MetaDraw.AddObjectDefault  Obj_Type%

The coordinates specifying the Right/Bottom corner of the bounding rectangle are ignored (and may be left out) for OT_TEXT and OT_IMAGE objects.

Upon adding a new object to the image the Current property contains the handle of this new object. This is an excellent time to either save the Current property to some variable, or to set an object tag for later identification of the object.

Note: Objects added programmatically using the AddObject method are NOT automatically selected. Any previously existing selection is left unchanged. You can however select the new object by setting the ObjSelected property immediately after adding the object.

Each object is created with default attributes, including color, line style, and fill style. These attributes may be set before creation of the object by setting the Current property to OBJ_DEFAULT (4) and then setting the appropriate attribute properties. Attributes may also be modified any time after creation by setting the Current property to point to the object (as it will by default immediately after object creation), and setting the appropriate attribute properties.

Each new object is always added to the top of the object stacking order, which is at the end of object list. After the object has been created you can change its layering order, placement, size and attributes.

To add a Text object, specify an object type parameter of OT_TEXT. After creation of the object, it will contain an empty string. You should then use the Text property to specify a text string for the text object that has been created.

MetaDraw.AddObject OT_TEXT, 100, 200, 100, 200
MetaDraw.Text = "Display this text for the newly created Text object"
MetaDraw.FontSize = 12
MetaDraw.FontName = "Times New Roman"

Four styles of text objects are supported: Standard, Bounded, Boxed and Multi-Line. The TextStyle property may be set after creating a text object in order to specify the desired style, or may be set as a default in advance with the Current property set to OBJ_DEFAULT.

New text objects are initially placed placed at the coordinates of the AddObject method according to current text alignment as specified by the TextHAlign and TextVAlign properties. By default text objects are aligned Top Left – that is they are added with the top left corner of the first character at the X1, Y1 postion specified in the AddObject method call. If a different text alignment is desired the TextHAlign and TextVAlign properties should be specified while Current = OBJ_DEFAULT) before adding the text object.

The initial size of a new text object is determined by either the bounding rectangle specified in the AddObject call, or by the default fontsize if the specified rectangle has zero height and width (x1 = x2, y1 = y2). The FontSize may also be reset after adding the text object.

MetaDraw1.Current = OBJ_DEFAULT
MetaDraw1.Textstyle=TXT_BOXED
MetaDraw1.FontSize = 21
MetaDraw1.FontName = "Times New Roman"
MetaDraw1.TextHAlign = TXT_LEFT
MetaDraw1.TextVAlign =TXT_VCENTER
MetaDraw1.LineColor = vbBLue
MetaDraw1.Backstyle = OPAQUE
MetaDraw1.AddObject OT_TEXT, 100, 100,100,100
MetaDraw1.Text = "Display this text for the newly created Text object"

When adding Polylines,Polygons, or Bezier ob jects using the Addobject method, the shape is initially added with just two points using the coordinates specified. The desired full set of vertex points can then be specified using the SetParams method

With MetaDraw
    .AddObject OT_POLYGON, 140, 140, 160, 160
    ' reset points
    Dim points(10)
    points(0) = 100:  points(1) = 100
    points(2) = 100:  points(3) = 200
    points(4) = 200:  points(5) = 200
    points(6) = 200:  points(7) = 100
    points(8) = 150:  points(9) = 50
    firstpoint = 0
    numpoints = 5
    Label1.Caption = "Points Remaining = " _
          & .SetParams(firstpoint, numpoints, points, CRD_LOGIC)
End With

When adding Pies, Arcs or Chords using the AddObject method, the top right 90o of arc is initially added within the rectangular region specified by the parameters of the AddObject call. The desired span of the Pie, Arc, or Chord can then be specified by modifying the first and /or last point using the SetParams method.

Note that the arc is drawn in a counter clockwise fashion, and in the example below the angle is also measured counter clockwise from the positive X axis.

With MetaDraw
     CenterX = 150
     CenterY = 150
     Radius = 75
     .AddObject OT_ARC, CenterX, CenterY - Radius, _
                CenterX + Radius, CenterY
     ' reset points
     Dim points(4)
     angle1 = 30 * 3.14 / 180
     angle2 = 90 * 3.14 / 180
     points(0) = CenterX + Radius * Cos(angle1)
     points(1) = CenterY - Radius * Sin(angle1)
     points(2) = CenterX + Radius * Cos(angle2)
     points(3) = CenterY - Radius * Sin(angle2)
     firstpoint = 0
     numpoints = 2
     Label1.Caption = "Points Remaining = " _
        & .SetParams(firstpoint, numpoints, points, CRD_LOGIC)
End With

When adding Rounded Rectangles, the SetParams method may be used to adjust the width and height of corner ellipses.

When adding Dimension Lines, the terminators on either end may be modified using the LinkStyle, LinkFlags, LinkWidth and LinkHeight properties.

When adding Containers (object Groups), the newly added container is initially closed and will have zero width and height regardless of the specified coordinate parameters. To add object to a new container it should first be opened by using the ObjOpened property. After closing the container it's position and size will be determined by the minimum bounding rectangle surrounding the objects grouped by the container.

The following example creates a container, adds objects within the container,
and then closes the container.

With MetaDraw1
   .AddObject OT_CONTAINER, 0, 0, 0, 0
   .ObjOpened = True
   .AddObject OT_RECTANGLE, 100,120,300,220
   .AddObject OT_ELLIPSE, 33,60, 120, 280
   .ObjMove = MOVE_CONT_OPENED
   .ObjOpened = False
End With

To merge/insert/paste a picture as an object, load a bitmap, an icon or a metafile into the PictureImage property and call the AddObject method with the value OT_IMAGE for object_type%. The image held in the PictureImage property will then be added as a single object (ObjType will return 11 = OT_BITMAP) or as a container (0=OT_CONTAINER) if the picture in the PictureImage property is itself a metafile containing several objects.

When the specified height and width are zero ( top-left and right-bottom corner coordinates are the same) the new picture will be added at its original size and its top-left corner will be placed at specified coordinates. Otherwise, MetaDraw immediately sizes the inserted picture according to the specified boundaries.

After inserting a picture, you can use the SetBounds and MoveObjects methods to change the picture coordinates (placement and sizes).

' Add a bitmap from the file "IMAGE.BMP" with
' (10,20) coordinates for the left-upper corner
MetaDraw.PictureImage = LoadPicture("IMAGE.BMP")
MetaDraw.AddObject OT_IMAGE, 10, 20, 10, 20

External Images can also be inserted (merged) into the current picture by:

· By Setting the PictureClip property

· Adding from the PictureImage property with the mouse (EditMode is ED_IMAGE)

· Calling the PasteFromClipboard method


Setting Default Attributes

Attributes of shapes, links or text ( such as LineColor , LinkStyle, Font, etc ) may be set up before a user starts drawing or before an object is added to the image in code.

To define defaults, just set the .Current property to the value OBJ_DEFAULT and then set the desired attribute properties.

Example:

' set up defaults for Text and then put user in Text mode
With MetaDraw
    .Current = OBJ_DEFAULT
    .FontName = "Arial"
    .FontSize = 10
    .EditMode = ED_Text
End With

Example:

' set up defaults for line style and then add some shapes
With MetaDraw
    .Current = OBJ_DEFAULT
    .LineStyle = PS_SOLID
    .FillStyle = FS_DIAGONAL
    .FillColor = vbBlue
    .AddObject OT_ELLIPSE, 100, 100, 200, 200
    .AddObject OT_RECTANGLE, 100, 100, 200, 200
    'characteristics set after adding an object
    'override the and apply only to the just added object
    .FillStyle = FS_TRANSPARENT
End With


Selecting objects

To change an object's parameters, you generally need to select the object(s). A selected object is displayed with special markers (small rectangles at the corners of the boundaries). Setting the MarkerSize property to zero can hide the selection markers.

You can select an object either programmatically or by using the mouse.

Programmatically Selecting Objects

To change an object's selection status, set the Current property to the handle of the object you wish selected or unselected. Then, assign the ObjSelected property the value True to select object or False to drop selection.

If Current is OBJ_CONTAINER, all objects in the current open contained will be selected or dropped from selection.

Note: You can only select objects that are in the "objects list" of the current open container. Objects located in different containers can not be selected.

Using the mouse to select/unselect objects

Setting the EditMode property to ED_SELECT allows the end-user of a MetaDraw application to select objects using the mouse.

To select a single object, click the left mouse button on an object. The selection of all other objects will be dropped. For multiple selection hold down the SHIFT key while clicking each of the objects you want to select.

To select several objects at the same time, click the left mouse button outside any object, then drag the mouse to create a rectangle enclosing all the objects you want to select. All objects that are completely placed inside this rectangle become selected. To include objects only partially inside the selection rectangle, hold down the CTRL key before releasing the left mouse button. You may also begin the selection rectangle anywhere (even over the other objects) by holding down the SHIFT key before pressing the left mouse button and dragging the mouse.

To cancel the selection of objects, do one of the following:

  • To cancel the selection of some of the selected objects, hold down the SHIFT key and click the left mouse button on the object(s) you want to deselect.
  • To cancel the selection of all selected objects, click the left mouse button outside any objects or click the left mouse button on an unselected object twice.
Note: Selection of objects by the mouse can be disabled/enabled in the EditFlags property (EFLG_SELECT, EFLG_SELSHIFT and EFLG_SELGROUP flags).


Editing objects

Each graphic object within the MetaDraw image may be independently manipulated using MetaDraw's Properties and Methods, or by using the mouse while in EditMode ED_SELECT.

Programmatically changing an object attributes

To change the attributes of an object, specify its handle in the Current property and assign new attributes to corresponding properties (LineColor, FillColor, FillStyle, DrawMode, ...). If the specified object is a container, then the specified attribute is set for all objects of this container. Note that immediately after an object has been added to the drawing, the Current property is automatically set to point to that object making this a convenient time to set the attributes. Additionally default attributes may be set prior to adding objects by setting the Current property to the special value of OBJ_DEFAULT.

You can change one attribute for several selected objects at one time using one assignment. To do this, select the required objects, set the Current property to OBJ_SELECTED and set corresponding attribute property to a new value.

Note: Use the Text property to change strings of text objects.

You can change an object's placement and resize it programmatically using the SetBounds, MoveObjects methods.

Any additional object's parameters (rounded corners, sector start/end points, polyline/ polygon points, etc.) can be changed using the GetParam/SetParams methods.

Using the mouse to modify an object

It is easy to edit objects using the mouse. To do this, set the EditMode property to ED_SELECT. In this edit mode, the end-user can:

  • Select Objects (see the section above).
  • Move a Selected Object or group of objects
    Select the object(s) you want to move, click the left mouse button on one of the selected objects and drag the object(s) to the new location. Note that this can be disabled in the EditFlags property. While dragging object(s), you can hold down the CTRL key to disable/enable alignment to grid.
  • Resize an Object
    Select the object you want to resize (click the left mouse button on it), then click the left mouse button on one of the special markers and drag it. This feature can be disabled/enabled by setting the EFLG_RESIZE flag of the EditFlags property. During dragging marker you can hold down the CTRL key to disable/enable alignment to grid.
    MetaDraw allows you to keep the object's aspect ratio while resizing. To enable/disable this feature hold down the SHIFT key when you are dragging a marker. Note: MetaDraw keeps aspect ratio for several objects by default (bitmaps, containers, pictures).
  • Change Object's Additional Parameters (like rounded corners, sector's start and end points, reshaping a polyline or polygon).
    Double-click the left mouse button on an object you want to edit, drag one of the boundary markers to change the object's shape. If you have double-clicked the left mouse button on a container, it is "opened" and you can edit objects inside it (this feature can be disabled in the EditFlags property).
    Additional markers may be shown when an object (rounded rectangle, sector, arc, chord) is selected. So you don't have to double click on such object to change its additional data, just drag an yellow marker.
  • Add/Delete points.
    MetaDraw allows you to add/delete points to/from polygons/polylines. When you are editing a polyline/polygon, you may click the left mouse button on a straight line to add a new point. Also you can delete some points by holding the left mouse button on a point you want to delete and pressing the BACKSPACE key. You may press the BACKSPACE key as many times as many points you want to delete.
  • Edit Text Objects.
    When a Text object is opened you can extend the text by typing and remove text with the BACKSPACE key
    You can use the arrow keys to move the caret position while editing a text object and use the DEL key to remove a character at the current caret position.


Deleting objects

To delete an object, specify its handle in the Current property and call the RemoveObject method:

MDraw.RemoveObject

To remove several objects, select the objects you want to delete, then call the RemoveObject method with parameter OBJ_SELECTED:

MDraw.RemoveObject OBJ_SELECTED

To delete all objects in the open container, use the RemoveObject method with parameter OBJ_CONTAINER:

MDraw.RemoveObject OBJ_CONTAINER

This deletes the container and all objects from the container, and will open the parent container.

After removing an item, the Current property contains:

  • OBJ_NULL, if an object handle was specified for deleting
  • Don't change, if a reserved handle (OBJ_SELECTED or OBJ_CONTAINER) was specified.

You can only delete object(s) from an open container. Objects within a closed container may not be deleted without first opening the container.

You can even delete an object inside a closed container by specifying its handle in the RemoveObject method.

Keyboard Deletions

MetaDraw does not currently provide any direct keyboard support for end-users deleting objects. To implement this functionality trap the KeyUp event and call the RemoveObject method as appropriate:

Sub MDraw_KeyUp(KeyCode As Integer, Shift As Integer)
' This subroutine deletes a selected object in response to the Delete key
' - checking first to avoid deleting Text objects which are
' open for editing ( in which case delete key should simply delete a character)
     With MDraw
        If KeyCode = vbKeyDelete Then
            ' Check if there is something selected to delete
            If .ObjCount(OBJ_SELECTED) > 0 Then
                ' move to the currently selected object
                .ObjMove = MOVE_SEL_FIRST
                ' make sure object is not an text object open for editing
                If .ObjType = OT_TEXT Then
                    If .ObjOpened = True Then
                        ' do not remove open text objects
                        Exit Sub
                    End If
                End If
                .RemoveObject .Current
            End If
        End If
     End With
End Sub


Grouping or ungrouping drawing objects

The MetaDraw control allows you to group several objects into one container. This allows you to treat many objects as a single unit. After several objects are grouped into a container you can move and resize them together as a single object. Containers are themselves sometimes referred to as a group.

To group objects into a container select them and then set the Current property to OBJ_SELECTED to point to all selected items. Next, set the Action property to ACT_GROUP. This creates a new object (a container) which is added to the Objects List. All selected objects will be moved into the container. The new container becomes selected, and the Current property contains the handle of the container object. This is a good time to set an Object tag for later identification of the container.

Examples:

' add a vertical line
MetaDraw.AddObject OT_LINE, 200, 200, 200, 400
' select this line
MetaDraw.ObjSelected = True
' add a horizontal line
MetaDraw.AddObject  OT_LINE, 100, 100, 300, 300
' select this line
MetaDraw.ObjSelected = True
' point to selected objects
MetaDraw.Current= OBJ_SELECTED
' create a group
MetaDraw.Action = ACT_GROUP
' Save the handle as a group  identifier
GroupHandle = MetaDraw.Current
' Set a Tag to identify the group
MetaDraw.ObjTag = "SomeString"
' MetaDraw supports multiple named tags for each object.
MetaDraw.ObjTags("NamedTag1") = SomeValue

To ungroup a container, specify its handle in the Current property and set the Action property to ACT_UNGROUP. All objects from the container will be moved up one level in the objects list (after ungrouping the container) and the empty container will be removed. You can ungroup many containers at once. Select the containers, and set the Current property to point to all selected objects (=OBJ_SELECTED). Then, apply the action ACT_UNGROUP.

Containers may also be Opened for Manipulation in EditMode ED_SELECT, by double clicking on the group. Double Click again to close the group.


Rotating an object

90 Degree Rotations

You can rotate an object to the right or to the left in 90° increments.

To rotate an object by 90° specify its handle in the Current property and assign the Action property with one of the following values:

ACT_ROTATELEFT | - To rotate object in a clockwise direction
ACT_ROTATERIGHT | - To rotate object by a counter clockwise direction

If the Current property specifies several objects (OBJ_SELECTED or OBJ_CONTAINER), all objects will be rotated independently.

Note that rotating an object may distort the picture. This is true because resolution of the device may not be the same in X and Y directions.

Arbitrary Angle Rotation

MetaDraw supports rotation of image components at any angle. You can rotate objects programmatically using the ObjRotation property (rotates about the center point of the object), or the RotateObjects method (for rotation about any point).

For text objects which have been associated as LinkLabels on Lines, Links, or Dimension Lines, the OS_LINKANGLE flag in the ObjStatus property determines whether the angle is relative to the horizontal axis, or to the angle of the associated Line, Link or Dimension Line

End-User rotation by mouse dragging is also supported under the new edit mode -MetaDraw.EditMode = ED_ROTATE. In this mode the user selects an object and can rotate the object by dragging on one of the object corners.

Note: Only text objects using True-Type fonts can be rotated by MetaDraw. MetaDraw leaves text objects with other fonts unrotated.


Flipping an object

You can create a mirror image of an object by flipping it. MetaDraw allows you to flip text objects, but instead of creating a real mirror image, it draws the text in backorder.

To flip an object specify its handle in the Current property and assign the Action property with one of the following values:

ACT_FLIPHORZ | - To flip object(s) horizontally
ACT_FLIPVERT | - To flip object(s) vertically

If the Current property specifies several objects (OBJ_SELECTED or OBJ_CONTAINER values) all objects will be flipped independently.


Changing the layering order of objects

You can move an object in back or in front of other objects in the objects list.

To change the layering order of one or more objects, specify its handle in the Current property and set the Action property to one of the following values:

ACT_SENDBACK | - Send specified object(s) to the back of all other objects
ACT_MOVEFRONT | - Bring specified object(s) to the front of all other objects
ACT_ONEDOWN | - Move object(s) before previous object
ACT_ONEUP | - Move object(s) after next object

If the Current property specifies several selected objects (OBJ_SELECTED), then after assigning ACT_ONEDOWN or ACT_SENDBACK, all selected objects will be removed from the objects list (keeping with its stacking order). Then, they will be inserted before first object in the objects list (ACT_SENDBACK) or before the object in the list which is before first selected object (ACT_ONEDOWN).

Note that the layering order is the ordering system used by the ObjNumber property.


Converting File Formats

MetaDraw provides support for BMP, JPG, PNG, WMF, EMF, and MDP file formats. DXF format support is also available with MetaDraw DXF License Option.

To convert an image from one file format to another is simple. Just load the original image and resave in the desired format

MetaDraw.LoadPicture "InputFileName", PIC_PICTURE,

MetaDraw.SavePicture "OutputFileName", PIC_PICTURE, desired_format

Where <desired_format> can be any of the following:

Raster formats: |
PICTYPE_BITMAP | .BMP
PICTYPE_JPGFILE | .JPG
PICTYPE_PNGFILE | .PNG
PICTYPE_ICON | .ICO
Vector formats: |
PICTYPE_INTERNAL | .MDP
PICTYPE_METAFILE | .WMF
PICTYPE_ENHMETAFILE | .EMF
PICTYPE_DXFFILE * ( * DXF requires DXF license option) | .DXF


Support of UnDo / ReDo

MetaDraw 3 provides support for multi-step Undo and ReDo of changes to the image.

Support is provided for specifying how many changes to undo in one step and for grouping multiple actions into a single step to be undone in one operation.

Refer to the UnDo and ReDo Methods, and the UnDoLevels and UnDoGrouping Properties for further information.


Printing with MetaDraw

MetaDraw allows the picture (or portions of the picture) to be printed in any size at any location on the printed page. The picture can be merged with any other printable information using the Printer object. You can also draw the picture, or any part of it, in any window whose device context (hDC) you know - for instance you can print to the Windows desktop, to a form, or to a picturebox.

The Current property is used to specify what portion of the picture to print. To print the entire picture set Current to OBJ_CONT_MAIN. To print selected objects only, set Current to OBJ_SELECTED.

Setting the ExportDC property identifies the target device and starts the printing process. By setting this property it is possible to print to a physical printer, or to any window, for example a picturebox.

Note that when printing to a printer specified by it's DC, it is essential to initialize the printer (generally by printing an empty string using the printer.Print method) and to close the print job (generally by calling the Printer.EndDoc method).

Setting ExportDC to the special values -1, or -2, will direct the output to the default printer, or present the user with a printer selection dialog and then print to the chosen printer. When setting ExportDC to either of these values, MetaDraw initializes the printer, prints, and then ends the print job directly. There is no need for initialization of the printer or use of EndDoc statements to conclude the print job. The limitation is that in this case MetaDraw it is not possible to add additional information to the page before it is ejected.

MetaDraw triggers an Export event for each exported object. This allows you to write code for unique handling of each exported object (for example, display a progress indicator).

The properties ExportLeft and ExportTop specify the placement of the exported picture on the printer page or on the device's window. The ExportWidth and ExportHeight properties determine the size of the picture. These properties are generally specified in Twips, but may be specified in Pixels based on the setting of the ExportOptions property.

MetaDraw offers additional flexibility through use of the ExportOptions property. It is possible to crop the printed image by specifying a Clipping rectangle, as well as to optionally print the background of the image. It is also no longer necessary to set the ExportLeft, ExportTop, ExportWidth and ExportHeight properties. By default (if these properties are not set) MetaDraw will print the image at 0 offset on the page, and at the original size of the image.

Example

The following code prints the complete picture at its original (unzoomed) size to user's choice of printer:

Sub btnCommand_Click ()
    MDraw.Current = OBJ_CONT_MAIN  ' point to the whole picture
    MDraw.ExportDC = -2            ' print to printer chosen by user
End Sub

The following example prints a picture on the same page as text printed independently of MetaDraw:

Sub btnCommand_Click ()
    MDraw.Current = OBJ_CONT_MAIN  ' point to the whole picture
    Printer.FontName = "Arial"
    Printer.FontSize = 16
    Printer.ScaleMode = 3          ' Pixels
    Printer.Print ""               ' Initialize the printer
    Printer.Print "This picture was printed from MetaDraw"
    MetaDraw.ExportOptions = EXOPT_EXPORTRECT + EXOPT_PIXELS
    MetaDraw.ExportLeft = 720 / Printer.TwipsPerPixelX
    MetaDraw.ExportTop = Printer.CurrentY + 720 / Printer.TwipsPerPixelY
    MetaDraw.ExportWidth = MDraw.OrigWidth * _
            Screen.TwipsPerPixelX / Printer.TwipsPerPixelX
    MetaDraw.ExportHeight = 0 ' Metadraw will preserve aspect ratio
    MetaDraw.ExportDC = Printer.hDC
    Printer.NewPage
    Printer.EndDoc        ' close the print job
End Sub


Using HyperGraphic Hot-Spots

One of MetaDraw's really outstanding features (ok, so we're not so modest) is it's support for "HyperGraphic HotSpots".

You can load any metafile or bitmap into a MetaDraw control, and identify regions of any shape and size within the picture as hot spots. When dragging the mouse over a hotspot, or clicking the left mouse button, special events will be generated. Here you can pop-up a message box, load a new image, or take any other action appropriate to your application. Hotspots may even be used to control a web browse - jumping to a URL address.

For example, you can create a picture of a world map, and declare each continent as a hot spot by changing the ObjHotSpot property for each object or container (if the continent is made up of several objects). Then, you can determine the actions to take in the OnHotSpot and HitObject event (e.g., display the detailed information about the continent pointed by the user).

.

Below we list a some of the key properties and events which make MetaDraw ideal for HyperGraphic applications.

More:

HyperGraphic Events

HyperGraphic Properties

Creating HyperGraphic Images using HSEditor?

Programmatically creating Hypergraphic Images

Responding to Hypergraphic Events


HyperGraphic Events

(triggered only if EditMode = ED_VIEW (0), and HotSpots is set to True, and they are not masked in the EventMask property)

HitObject, HitObjectDouble | Fired in response to clicking on Hitable elements.
OnHotSpot | Fired in response to mouse entering a Hot graphic area.


HyperGraphic Properties

EditMode | triggers HyperGraphic events (HitObject, OnHotSpot), changes the mouse cursor, and executes URL jumps, when in EditMode ED_View.
HotSpots | determines whether to trigger HitObject HitobjectDouble, and OnHotSpot events in response to end-user actions when EditMode is ED_VIEW.
Modifications | a bit flag property – the status of the MOD_HITTHROUGH flag in this property determines whether for objects in a container group, whether to trigger OnHotspot and HitObject events for the individual objects or only for the container
ObjHotSpot | a bit flag property determining the events fired and/or actions automatically taken in response to mouse clicks or mouse movement over a hotspot. Actions may include triggering HitObject or OnHotSpot events, changing the mouse cursor, and instructing the web browse to execute a URL Jump.
ObjTag | holds a string assigned to an object, you can read this string to determine what data to display or action to take in response to end-user actions associated with a particular graphic element. MetaDraw has an additional property that allows you to determine multiple tags with different types and values.
ObjTags | an named vector property holding multiple named values assigned to an object. More versatile than the ObjTag property, objects assigned ObjTags values may also be found using the FindObjectTags method.
ObjVisible | determines whether or not to show a particular graphic element (which may just be the outline of a hotspot) when the ShowInvisible property is set to False.
ObjURL | identifies a URL associated with an object.
WebTargetFrame | Identifies a target frame into which loading occurs when executing a URL Jump.
WebUrlBase | adds the contents of ObjURL property to the value of the WebURLBase property to construct a full URL.

By setting the HotSpot property as described above you can create hotspots of any number, shape and size, over a large bitmap or other graphic elements. It is also possible to either display the main image within a picture box (setting MetaDraw's Background to Transparent), or to load the initial image into the MetaDraw BackPicture properly or as a Background Layer using the LoadPicture method.


Creating HyperGraphic Images using HSEditor?

Creating HyperGraphic Images using HSEditorÔ

We have provided a run-time only copy of our compiled Drawing / HotSpot Editor application (HSEditor) as an aid in creating your HyperGraphic images. You can use this tool to set up the image and hotspots.

  1. Load up an initial image or Create the image directly in HSEditor.
  2. Draw any additional shapes to define hotspot areas.
  3. Choose the Selection tool (arrow), and select an area you want to mark as a hotspot.
  4. Use the "Object/HotSpot Information" menu item to bring up the HotSpot Information Dialog. Here you can identify:
    - whether the hotspot object itself should be visible
    - what type of hotspot actions should be trapped
    - an object tag to associate with the hotspot
    - a URL to associate with the hotspot
  5. Test the image by selecting the Tools\Show HotSpots menu item.
    - Objects marked as Invisible will be hidden.
    - The mouse cursor will change when over an object marked as a HotSpot.
    - The HotSpot Information Dialog will be shown when clicking on a Hittable object.
    - The URL will be loaded in a Web Browser when clicking on an object with a defined URL.
  6. Save the HotSpot enhanced image from HSEditor. In order to preserve the hotspot and Tag definitions, make sure you save the image to MetaDraw format (.MDP).
  7. Include the image file with your distributed application, and load it into your application. The hotspots and associated object TAG definitions will remain defined within the image and will react properly in your application - triggering the OnHotSpot and HitObject events as needed.
* * License Note: DO NOT distribute the HSEditor application. This is included with MetaDraw for use by licensed MetaDraw developers only. Source code, and/or distribution rights for HSEditor may be separately purchased from Bennet-Tec.


Programmatically creating Hypergraphic Images

To set up a hypergraphic image programmatically (without HSEditor), follow these simple steps:

  1. First create or import the basic image you are interested in.
    This may be a vector-based image consisting of multiple graphic objects, or it may be a single large bitmap or metafile.
    Generally this image is loaded into the standard Picture property. The LoadPicture property may be used to load a background layer image.
  2. Second, add additional graphic elements within MetaDraw to define the shape and position of hotspots over the main image. These graphic elements may themselves be visible or invisible. You can add these elements as you would any visible elements - for instance, by end-user drawing, or by use of the AddObject method.
  3. To define a graphic element as a hotspot, set the ObjHotSpot and/or ObjStatus properties.
    You may also wish to set the ObjTag property (also ObjTags and ObjUrl in MetaDraw) to hold some specific data about the HotSpot. This additional data may then be read within the OnHotSpot and HitObjects events in the end-user application.
  4. Finally, if you do not want the hotspot shapes themselves seen by the end-user, set the 'ObjVisible' flag to False for these objects. These objects will not be seen under EditMode = ED_VIEW, and the ShowInvisible property set to False. They will however still react as hotspots.

For example the following code adds an ellipse as an invisible hotspot:

MetaDraw.AddObject OT_ELLIPSE, 10, 10, 200, 100 ' Add an ellipse
MetaDraw.ObjHotSpot = OS_HOTSPOT Or OS_CURSOR   ' Make it a hotspot
MetaDraw.ObjVisible = False                     ' Make it invisible
MetaDraw.ObjTag = "this is an ellipse"          ' Make it invisible

To mark an existing graphic element within an image as a "hotspot" or "hitable" you should assign the handle of this object to the Current property, and then set the ObjStatus or ObjHotSpot properties.

For example the following code might be used within a command button Click Event under EditMode = ED_SELECT. In response to the click, adds an ellipse as an invisible hotspot:

Sub CmdSetHotSpot_Click ()
    MetaDraw.Current = OBJ_SELECTED
    MetaDraw.ObjHotSpot = OS_HOTSPOT Or OS_CURSOR Or OS_CLICK
    MetaDraw.ObjTags ("A Named Tag") = TextboxTag.Text
    MetaDraw.ObjTags ("Another Tag") = TextboxTag1.Text
End Sub


Responding to Hypergraphic Events

When you run your application for the end-user to work with, make sure that

  • the EditMode property is set to ED_VIEW (0),
  • the HotSpots property is set to True,
  • and the ShowInvisible property is set to False.

Trap the OnHotSpot event to take action when the mouse enters, leaves, or moves within a hotspot are.

Trap the HitObject event to take action in response to a user clicking on a hotspot.

In either event it is generally useful to read the ObjTag and/or ObjTags properties.

Examples:

Sub MetaDraw_HitObject (X As Long, Y As Long)
    'Load a new image based on the ObjTag of the hotspot object
    NewPictureFile = MetaDraw.ObjTag
    MetaDraw.LoadPicture NewPictureFile, PIC_PICTURE
End Sub
Sub MetaDraw_HitObject (X As Long, Y As Long)
    'Display data from multiple ObjTags of clicked hotspot
    Label1.caption = Metadraw.ObjTags("partName")
    Label2.caption = Metadraw.ObjTags("Vendor Name")
    Label3.caption = Metadraw.ObjTags("Quantity in Stock")
End Sub

Web links in MetaDraw set with the ObjURL property and Status property flag OS_WEBURL, are automatically handled by MetaDraw. There is no need to trap any events or write any code to control the web browser. MetaDraw will take care of this directly.


Working with the Internet

In addition to HotSpot automatic jumps to a Web page (see ObjStatus or ObjHotSpot properties), MetaDraw also facilitates direct programmatic control over a web browser.

The WebNavigate, WebGoBack, WebGoFoward methods instruct the web browser to go to a specific URL or to go forward or back within the browser's recent history list.

MetaDraw may also be used as an ActiveX control embedded within a Web page. You may use special tools to add MetaDraw to your web page (e.g. Microsoft Control Pad). Or you can add the MetaDraw control to the web page using the following code:

<OBJECT ID="MetaDraw1" WIDTH=100% HEIGHT=100%
  CLASSID="CLSID: 32308000-644D-A583-AD61-00403333EC93"
  DATA="MetaDrawImageFile.MDR">
</OBJECT>

"MetaDrawImageFile.MDR" may actually be any valid URL pointing to a MetaDraw data format (.MDR) file as prepared by the SaveData method or created in the design-time mode. An .MDR file contains full information about the MetaDraw control.


Drag-and-Drop operations

The MetaDraw control supports both File Drag and Drop as well as dragging and dropping controls in Visual Basic.

For more information about dragging and dropping controls, see the Microsoft Visual Basic Language Reference and Programmer's Guide.

Dropping files from FileManager or Windows Explorer

One or more files selected in the File Manager or Windows Explorer can be "dragged" by the mouse to a given location inside the MetaDraw control box and "dropped" into it.

When the file names are dropped on the MetaDraw control, the DropFile event is fired. Depending upon the DropMode property setting, it is fired for every dropped file or only for the first file in a group of dropped files. If DropMode is zero, files are not allowed to be dropped into MetaDraw's window.

There is no default processing for dropped files, only the event is fired. To process the files, put code in the DropFile event. In the simplest case (the code is shown below), the first named file is loaded into MetaDraw (it is assumed to be a picture).

Sub MDraw_DropFile (X As Integer, Y As Integer, _
                   FName As String, Idx As Integer)
    On Error Resume Next: Err = 0
    MDraw.LoadPicture FName, PIC_PICTURE
    If Err Then MsgBox "Can't load " & FName & ":" & Error$
    Idx = -1        ' Cancel the next files
End Sub

MetaDraw also supports OLE Drag&Drop technique, that can be used to drop files/pictures into MetaDraw picture.


How to count and loop through objects in an image

The ObjCount property of MetaDraw may be used to count the number of objects in the overall image, as well as the number of objects within a given container or the number of selected objects.

It is possible to loop through objects within MetaDraw (or within a selection) using the ObjMove property. This method updates the Current pointer.

' This counts the number of rectangle objects within
' the selected objects
Sub GetSelectedTypes (MD As MetaDraw)
    RectangleCount = 0
    ' move .Current to first selected object
    MD.ObjMove = MOVE_SEL_FIRST
    While MD.Current <> OBJ_NULL
        If MD.OBJType = OT_RECTANGLE Then
            RectangleCount = RectangleCount + 1
        End If
        ' move .Current to next selected object
        MD.ObjMove = MOVE_SEL_NEXT
    Wend
    Print "There are " & Str$(RectangleCount) "rectangles")
End Sub

The following example shows how you can loop through all objects (even those inside containers) in the MetaDraw picture to assign their type name and order number in the ObjTags property. Objects are enumerated in this example in the following order. Object 1 is the first object in the main container. If this is a container then the 2nd object is the 1st object within this container. Otherwise, it is the next object inside the main container.

Sub EnumerateAllObjects()
    Dim TotalObjects As Long, LastObject&

    ' Move Current pointer to the main container
    MDraw.ObjMove = MOVE_CONT_MAIN
    LastObject& = MDraw.Current
    MDraw.ObjOpened = True
    ' Move Current pointer to first object in the main container
    MDraw.ObjMove = MOVE_CONT_FIRST
    TotalObjects = 0
    While MDraw.Current > OBJ_VALID
        TotalObjects = TotalObjects + 1
        ' Assign the object data
        MDraw.ObjTags("Type") = GetObjectTypeName(MDraw.ObjType)
        MDraw.ObjTags("Number") = TotalObjects
        LastObject& = MDraw.Current

        ' If the object is a container then loop through it
        If MDraw.ObjType = OT_CONTAINER Then
            MDraw.ObjMove = MOVE_CHILD_FIRST
        Else
            MDraw.ObjMove = MOVE_NEXT
        End If

        ' if we reach the last child object in the container
        ' we should go up to previous container
        Do While MDraw.Current < OBJ_VALID
            MDraw.Current = LastObject&
            MDraw.ObjMove = MOVE_PARENT
            If MDraw.Current < OBJ_VALID Then Exit Do
            LastObject& = MDraw.Current
            MDraw.ObjMove = MOVE_NEXT
        Loop
    Wend
End Sub

MetaDraw also allows you to refer to an object by its order number (inside a container). You can set the Current object to the desired object by assigning its order number to the ObjNumber property.

The following code shows how you can loop through the objects inside the current open container using the ObjNumber property. Note that this method is much slower then previous one.

Sub ScanOpenContainer()
    Dim Total As Long, I%
    ' Get the number of objects inside the current open container
    Total = MDraw.ObjCount(OBJ_CONTAINER)
    For I% = 1 To TotalObjects
        MDraw.ObjNumber = I%
        ' The Current property contains a handle of next object
        MDraw.ObjTags("Type") = "Type: " & MDraw.ObjType
    Next I%
End Sub


How to search for objects within MetaDraw

It is frequently desirable to find a specific object within the overall image. There are several ways in which this may be done.

Method 1 | Loop through the objects using the ObjMove or ObjNumber properties and look for ObjTags or other object's identification.
Method 2 | Save the Handle (specified by the Current property) when the object is created and simply set the Current property to this handle in order to refer to the object at a later time.
Method 3 | It is possible to use the FindObjectTags method to search for an object according to one or more tags assigned to the object. This is very powerful - in fact one can search for exact matches or substrings, case sensitive or not, even restricting the search to selected items only.


How to create and manipulate diagram links

MetaDraw supports a special object type called a Link. Links are picture elements displayed as straight lines or segmented lines with optional arrow heads which connect any two other picture elements (not including other links).

Links are very powerful - When a linked object (an object connected to another object by a link) is moved, MetaDraw will automatically update the link to maintain the connection.

Text objects may also be associated with links as Link Labels. Such text objects are automatically moved with the link. They may also be aligned to (angled with) the link depending on the OS_LabelAngle flag in the ObjStatus property.

Using the properties ObjLinks, ObjLinkCount and LinkObject it is possible to programmatically follow the flow from one linked object to another. Additional detail stored in Object Tags can then be used to provide full information about some process flow.

More:

Code Based Creation and Manipulation of Diagram Links

End-User Creation and Manipulation of Diagram Links

Limitations of MetaDraw Links


Code Based Creation and Manipulation of Diagram Links

To create a link between two or more Objects, call the CreateLink method. Specify the start and end points of the link as objects, and a link type (0 for straight line links, 1 for multi-segmented links). A link object will be created (object type = OT_LINK, or OT_POLYLINK) and drawn to connect the objects as specified. After creating a link the Current property will contain the handle of the link.

MetaDraw.CreateLink Object1&, Object2&, LinkType

To create a link from one object to multiple other currently selected objects, specify the first object handle as the initial object in the CreateLink method and specify OBJ_SELECTED as the second parameter.

MetaDraw.CreateLink Object1&, OBJ_SELECTED, 0

To delete a link - use the RemoveObject method as with any other object. If a linked object is deleted, any link objects connecting to that object are also deleted.

Links may be selected as with any other type of object within MetaDraw. A link can be grouped with its linked objects into a container.

Properties which define Link attributes include:

LinkStyle | specifies whether to draw arrow heads or other link terminators on one or both ends of a link, or as a center symbol in the middle of a link.
LinkLength / LinkWidth | determine the length and width of Link terminators or of center symbol
LinkFlags | specifies additional details for drawing of link terminators and center symbol
LinkObject | specifies the handle of the object to which a link is attached. This can be used to change the objects being linked.
ObjLinkCount | returns the number of Links which are attached to some object
ObjLinks | returns the handle to a link object which is connected to some object
LinkLabel | identifies a text object as a Label for the link. Setting LinkLabel will move the text object to the link, and the text will then automatically move with the link as the link itself is updated. The OS_LABEL_ANGLE flag in the ObjStatus property can be used to specify how the text is oriented relative to the link line.
LinkSymbolColor | specifies the color used in display of link symbols ( link terminators or link center symbol)

The LineStyle, LineColor and LineWidth properties determine the style and width of link lines. The FillStyle, FillColor properties determine the fill style of link terminators.

Most other properties which apply to MetaDraw objects may also be applied to links:

Current, LineStyle, LineWidth, LineColor, FillStyle, FillColor, FillPattern, ObjTag, ObjTags, ObjSelected, ObjHotSpot, ObjURL, ObjTop (Left, Right, Bottom), ObjStatus, ObjType, ObjVisible.

Additionally the SetLinkPoint method may be used to change the coordinates where a link is terminated relative to the center of the linked object upon which the link terminates. By default the link is terminated at the nearest edge of the linked object.

For MultiSegmented Links ( PolyLinks) the GetParams method may be called to retrieve the number of vertext points in the link's trace (i.e. dynamic points between terminators). The SetParams method may be called to modify the connection or vertex locations (bends).

There are 3 ways to modify a PolyLink via SetParams:

  1. To modify only its trace (terminators will be updated automatically).

    It is necessary to pass 2 as the 1st parameter and the number of points gotten from GetParams as the 2nd one to the SetParams method.

Dim lArray() As Long, lPoints As Long, i As Long
ReDim lArray(0 To 0)
With MetaDraw1
    .Current = lLink
    lPoints = .GetParams(0, 0, lArray(0), CRD_LOGIC)
    ReDim lArray(0 To lPoints * 2 - 1)
    .GetParams 2, lPoints, lArray(0), CRD_LOGIC
    '- shift link points to the right
    For i = 0 To UBound(lArray)
        If (i Mod 2 = 0) Then lArray(i) = lArray(i) + 50
    Next
    .SetParams 2, lPoints, lArray(), CRD_LOGIC
End With
  2. To modify the entire Link object (including explicit setting positions for terminators).

    It is necessary to pass 0 as the 1st parameter and the number of points gotten from GetParams increased by 4 as the 2nd one to the SetParams method. The 4 additional points are the 2 ending points touching the linked objects and 2 possible additional points ("pokers") appearing in some situations.

Dim lArray() As Long, lPoints As Long, i As Long
ReDim lArray(0 To 0)
With MetaDraw1
    .Current = lLink
    lPoints = 4 + .GetParams(0, 0, lArray(0), CRD_LOGIC)
    ReDim lArray(0 To lPoints * 2 - 1)
    .GetParams 0, lPoints, lArray(0), CRD_LOGIC
    '- shift link points to the
    For i = 0 To UBound(lArray) right
        If (i Mod 2 = 0) Then lArray(i) = lArray(i) + 50
    Next
    .SetParams 0, lPoints, lArray(), CRD_LOGIC
End With
  3. To automatically route the link in an "optimal" path

    MetaDraw can automatically adjust a segmented link to find a "optimal" path, with a minimal number of bends and attempting to pass around other objects without moving any objects. This is done by calling the SetParams method, with a second parameter ( num points) of 0 ( zero points). The 1st parameter of the SetParams method may be used for setting distance to objects being bypassed.

Dim lArray(0) As Long
MetaDraw1.Current = lLink  ' point to the link to be rerouted
MetaDraw1.SetParams 200, 0, lArray(), 0


End-User Creation and Manipulation of Diagram Links

Setting the EditMode property to ED_LINK allows the end-user to create links between objects using the mouse. In this edit mode the user can click on first one object and then another to establish the link. To create a multi-segmented link ( a link with bends) the user should hold down the <ALT> key when clicking on the first object.

Setting the EditMode property to ED_SELECT allows the user to double click on a link to "open" it for editing ( a link may also be opened by setting the ObjOpened property to True when Current points to the link). With the link open connection and vertex markers ( for segmented links) will be shown:

as blue diamonds (for automatic connection points)

or green diamonds (for fixed connection points ).

Yellow circles for vertex points of segmented links

The MarkerSize property determines size of diamonds & circles.

The user may then dragging on the diamond markers ( click and hold left mouse button over the marker) to change the position of the corresponding connection point. After the left mouse is released the connection point become fixed (green).

Dragging connection points with the mouse on a marker without holding down any keyboard keys will move the points along the outside border of the connected object – ( the connection point will be placed at the intersection of object's border and the line traced from the center of the object and current mouse position).

Depressing the <SHIFT> key while dragging connection points allows the connection point to be moved off the objects border, the connection point will be placed directly under the current mouse position.

Depressing the <CTRL> key while dragging points switches the align to grid behavior ( if align to grid is on, depressing the <CTRL> key allows moving without regard to the grid, if align to grid is off depressing the <CTRL> key keeps the points aligned to the grid

Depressing the <ESC> key while dragging the connection point makes that point automatic.

Depressing the <ALT> key while dragging a connection point allows the user to change the object the link is connected to ( the connection will be made to the object under the mouse cursor)

As with other user drawn shapes, default characteristics may be set in advance of user drawing by setting attributes while the Current property is set to OBJ_DEFAULT.


Limitations of MetaDraw Links

  • It is not currently possible to create a link to a Link object.
  • Links can not currently be drawn between objects within two different groups/containers. When a linked object is included within a container group, the link to that object will be broken and no longer displayed. To keep the link you must group it with both linked objects. Nothing happens with links if the container group is opened. When the container that contains a link is ungrouped, the link object will be moved up to the same layer where the linked objects will be located.
  • When saving an image to file, or copying to the clipboard, links are only maintained within MetaDraw's own proprietary format (.MDP or .MDR). When saving to file formats other than MDP or MDR or when copying these formats to the clipboard in a format other than CF_INTERNAL, the actual link recognition will be lost –only the visual representation of the link ( as line or lines with arrow heads) will be preserved rather than the link itself.
    In WMF or EMF format file the elements making up the link are saved in a container ( as a group).
  • The following methods are not supported for Link Objects

    SetBounds, MoveObjects, RotateObjects,
    CreateLink (linking a link to another object)

Example:

Sub CreateLink()
    ' assume two objects are selected by the user in EditMode = 11
    ' this routine then creates a link between the two objects
    If MetaDraw.OBJCount(OBJ_SELECTED) <>2 Then Exit Sub
    MetaDraw.ObjMove = MOVE_SEL_FIRST ' point to 1st selected object
    ObjHandle1 = MetaDraw.Current
    MetaDraw.ObjMove = MOVE_SEL_NEXT ' point to next selected object
    ObjHandle2 = MetaDraw.Current
    MetaDraw.CreateLink ObjHandle1 , ObjHandle2, 0   ' create link
    ' previous 5 lines may be replaced with the following line
    '  MetaDraw.CreateLink OBJ_SELECTED, OBJ_SELECTED, 0
    MetaDraw.LinkStyle (0) = 0       ' no terminator at origin
    MetaDraw.LinkStyle (1) = 6       ' Arrow points to target
    MetaDraw.LineStyle = PS_DASH     ' dashed link line
    MetaDraw.LineColor = vbBlue      ' blue link line
End Sub
Sub ExchangeLinkTerminators()
    ' This routine exchanges the terminators on a link
    ' Assume that the link is selected
    MetaDraw.ObjMove = MOVE_SEL_FIRST  ' act on selected object
    If MetaDraw.ObjType <> OT_LINK Then Exit Sub ' check object type
    Temp = MetaDraw.LinkStyle (0)
    MetaDraw.LinkStyle (0) = MetaDraw.LinkStyle (1)
    MetaDraw.LinkStyle (1) = Temp
    Temp = MetaDraw.LinkFlags (0)
    MetaDraw.LinkFlags (0) = MetaDraw.LinkFlags (1)
    MetaDraw.LinkFlags (1) = Temp
End Sub
Sub SetLinkPoint()
    ' This example creates two objects and a link
    ' that connects the left-bottom corner of the rectangle
    ' and the center of the ellipse
    MetaDraw.Current = OBJ_CONTAINER
    MetaDraw.ObjSelected = False    ' Drop selection
    MetaDraw.AddObject OT_RECTANGLE, 100, 100, 400, 200
    MetaDraw.ObjSelected = True     ' Select the object
    MetaDraw.AddObject OT_ELLIPSE, 300, 400, 700, 600
    MetaDraw.ObjSelected = True
    MetaDraw.CreateLink OBJ_SELECTED, OBJ_SELECTED, 0
    MetaDraw.SetLinkPoint LNK_START, -150, 50, CRD_LOGIC
    MetaDraw.SetLinkPoint LNK_END, 0, 0, CRD_LOGIC
End Sub


How to Optimize Diagram Layout

MetaDraw can automatically adjust a segmented link to find a "optimal" path, with a minimal number of bends and attempting to pass around other objects without moving any objects. This is done by calling the SetParams method, with a second parameter ( num points) of 0 ( zero points). The 1st parameter of the SetParams method may be used for setting distance to objects being bypassed.

Dim lArray(0) As Long
MetaDraw1.Current = lLink  ' point to the link to be rerouted
MetaDraw1.SetParams 200, 0, lArray(), 0

The Diagram Arrange library allows MetaDraw to rearrange objects (not just the diagram links) within the overall image in such a way as to minimize overlapping links and to lay out the diagram in an "organized" fashion. Objects which are not linked may also be layed out in a rectangular grid fashion using this function.

Caveats

The Diagram Arrange mechanism does NOT support segmented links.

The algorithm for finding optimal path for segmented links, and the Diagram Arrange library algorithm for repositioning objects connected by straight links, are proprietary to Bennet-Tec. Be aware that each image may result in different arrangements, that such arrangements are the result of calculations which are not subject to negotiation or to standards of what might be better or worse. Bennet-Tec does not guarentee that our "optimized" layouts will fit with your application's definition of an optimized layout. If you are interested in modified arrangements Bennet-Tec can take on sponsored (paid) development projects to tune the layout to your needs.

Requirements:

Development use of the Diagram Arrange DLL requires purchase of both the MetaDraw 3 license and the optional Diagram Arrange license option for MetaDraw 3. When distributing an application using the Vectorization features both the MetaDraw 3 control (MDRAW30.OCX) and the Diagram Arrange DLL (BTOA.DLL) must be installed on the end-user machine.

Technique:

The Diagram Arrange functionality is provided through a single Method call - ArrangeObjects

Calling the ArrangeObjects method repositions objects within a diagram to optimize layout of linked objects, or to lay unlinked objects in rectangular grid.

Return_Code = MDraw.ArrangeObjects (OBJ_CONTAINER, _
                                    TargetLeft, TargetTop, _
                                    TargetRight, TargetBottom, _
                                    MinX, MinY, Mode, 0)

Parameters of this method which elements to arrange within an MetaDraw diagram, the desired bounding rectangle for the resulting arrangement, desired minimum distances between objects, and method of arrangement: Rectangular, Unbound Link, BoundLinked

Refer to the technical specification on the ArrangeObject method for additional details.


How to set and manipulate the Background

1. BackPicture, BackPictureAlignment, Gradient style

2. ClearEdge Support

Exporting with EXOPT_BACKGROUND
Scrolling with PICOPT_BACKGROUND


How to create transparent bitmap objects

MetaDraw allows you to create Bitmap objects with a transparent color. You can choose any color of a bitmap that should be transparent.

To draw any bitmap object with transparency,

  • Set the Current property to the handle of the bitmap object (or OBJ_SELECTED if the bitmap(s) is(are) selected)
  • Set the BackStyle property to TRANSPARENT (= 0)
  • Set the BackColor property to that color which should be considered transparent.

After that if the bitmap contains pixels with the same color as specified in the BackColor property, these pixels will not be displayed (bitmap will look transparent in those places).

Note that when saving a picture from MetaDraw to MetaFile format ( WMF), the MetaFile format does not support true transparent background on bitmaps so MetaDraw represents such objects as superimposed images within the Metafile. True saving of transparent bitmap can only be supported in MetaDraw internal format.


How to Add Object Shadows

Metadraw provides support for the presentation of "shadows", basically a solid colored duplicate of the object shape offset from the original by some distance. The ObjShadow property can be set to 1 or 2 to display the shadow. The ObjShadowColor can be used to specify a shadow color, and ObjShadowOfsX and ObjShadowOfsY specify the offset distance (in logical units) of the shadow from the original object.

' Add a shadow to all selected objects
MetaDraw.Current = OBJ_SELECTED
MetaDraw.ObjShadow = 1
MetaDraw.ObjShadowOfsX = 50
MetaDraw.ObjShadowOfsY = 50


How to work with FloodFills

The easiest way to specify a fill for a single object shape is to set the FillStyle, FillColor, or possibly the FillPattern properties for that object.

With MetaDraw
    .AddObject  OT_ELLIPSE, 100,100,200,200
    .FillStyle = FS_CROSS
    .FillColor = RGB (100,100,200)
End With

MetaDraw also provides support for filling any bounded area with a color, bitmap or pre-defined pattern. For instance it is possible to fill the triangular area defined by the intersection of three lines, or the area of intersection between an ellipse and a rectangle. This may be accomplished by adding a FloodFill object at any point within the enclosed area using the AddObject method

For example:

With MetaDraw
    .AddObject  OT_ELLIPSE, 100,100,200,200
    .AddObject  OT_RECTANGLE, 150,.150,250,250
    .AddObject OT_FLOODFILL, 175,175,175,175
    .FillStyle = FS_CROSS
    .FillColor = RGB (100,100,200)
End With

FloodFill objects added with the AddObject method are positioned using only the Left and Top coordinates parameters. The Right and Bottom parameters are ignored.

FloodFill objects always have 0 width and height: ( ObjTop = ObjBottom, ObjLeft = ObjRight ) regardless of the extent of the region which is filled.

FloodFill objects can be selected and dragged just like other objects. They may however be difficult to click on given they have no height or width – if dragging Floodfill objects is to be enabled in an application it is helpful to increase the MarkerSize and HitSensitivity properties.

The extent of fill produced by a floodfill object responds dynamically to changing boundary objects. If objects are moved, added, or removed in the drawing the floodfill object will be redrawn according to the new boundaries around its location

Gradient Fill Style is not currently supported for FloodFill objects.


How to specify a grid

MetaDraw offers the ability to display a Grid and to align objects to that grid.

The GridShow property determines whether or not to show the grid , it is also possible to specify the grid to be above or below the image. The grid spacing is then determined by the GridHeight and GridWidth properties, and the determination of restricting items to a grid is set by the GridAlign property as well as by keyboard action.

The GridStyle property determines the style of Grid to be displayed: Dots ( shown only at Grid Points) , SolidLines, DottedLines, or DashedLines.

The GridColor property determines the color of Grid lines or Grid Dots.


How to Cut, Copy, and Paste

MetaDraw does not support Cut and Paste operations directly, but you can use several techniques to add this functionality to your application:

Using MetaDraw's temporary picture

You can use the Action property to copy MetaDraw's objects to the temporary image (given the PictureImage property) and then insert them back to MetaDraw.

The following example shows how to copy some selected objects from one container to another one using the temporary image.

' Assume that some objects have been already selected
' in the current open container
MetaDraw.Current = OBJ_SELECTED
MetaDraw.Action = ACT_IMAGECOPY
MetaDraw.Current = SecondContHandle&
MetaDraw.ObjOpened = True        ' Open another container
MetaDraw.Action = ACT_IMAGEINSERT
' it's possible to move the objects around the container here

Using the PictureClip property

You can use the PictureClip property which refers to selected objects inside open container to copy them from one MetaDraw picture to another one. The following example moves all selected objects from MetaDraw1 picture to MetaDraw2 picture.

' Assume that some objects are selected
MetaDraw1.Current = OBJ_SELECTED
' v-- use metafile as a temporary picture
MetaDraw1.PictureType = PICTYPE_METAFILE
' v-- copy objects from MetaDraw1 to MetaDraw2
MetaDraw2.PictureClip = MetaDraw1.PictureClip
' v-- remove objects that have been copied
MetaDraw1.RemoveObjects OBJ_SELECTED

Using the clipboard

To exchange pictures between deferent applications you can use the clipboard.

The following example shows how you can copy the MetaDraw picture into the clipboard in VB environment.

Private Sub mnCopy_Click()
    Clipboard.Clear     ' clear old clipboard contents
    ' Copy the whole MetaDraw picture to the clipboard as a bitmap
    MDraw.PictureType = PICTYPE_BITMAP
    Clipboard.SetData MDraw.Picture
    ' Add to the clipboard a metafile that has been created
    ' from the selected objects
    MDraw.PictureType = PICTYPE_METAFILE
    MDraw.Current = OBJ_SELECTED
    Clipboard.SetData MDraw.PictureClip
End Sub

MetaDraw has special functions for the clipboard support. They allows you to copy the MetaDraw picture (or any part of it) to the clipboard and insert an image from the clipboard to the MetaDraw picture.

CopyToClipboard (ByVal ClBrdMask As Integer [, ByVal PicSrc As Integer])
PasteFromClipboard (ByVal ClBrdMask As Integer [, ByVal PicDst As Integer])

You can copy to the clipboard as many formats as you want. The following line clear the old clipboard content and stores to the clipboard the main picture in two formats: as a bitmap and as a metafile.

MetaDraw.CopyToClipboard CLB_CLEAR+CLB_BITMAP+CLB_METAFILE, PIC_PICTURE

Using the PasteFromClipboard function you can insert an image from the clipboard to MetaDraw picture or replace the main or temporary picture by the image from the clipboard depending on the PicDst parameter. You can specify format you want to extract from the clipboard in the ClBrdMask parameter.

' The following line inserts an enhanced metafile from
' the clipboard to the current MetaDraw picture
MetaDraw.PasteFromClipboard CLB_ENHMETAFILE, PIC_PICTURECLIP

The PasteFromClipboard method may also be used to test if an image with a specific image format is currently held in the clipboard.

' The PIC_CHECKCLBFORMATS flag may be used to check
' if some specific image format exists in the clipboard
IsBMPFormatAvailable =
       ( CLB_BITMAP = MetaDraw1.PasteFromClipboard(
                  CLB_BITMAP, PIC_CHECKCLBFORMATS) )
Note: If you specify several formats in the ClBrdMask parameter, MetaDraw will choose the best format automatically.


How to Add, Remove or Change Points ( Verticies) in a Polygon or PolyLine

The SetParams method may be used to add, remove, or change the position of points (vertices) in a polygon, polyline, or multi-segmented link

The 1st parameter of the SetParams method indicates the where in the sequence to insert, remove or adjust location of points. The first point is point 0, the second is point 1, . . . Also it is possible to refer to point by relationship to the last point; to add after the last point use a value of -1. To delete or modify the last refer to point number - 2, the next to last point is -3, ...

The 2nd parameter indicates the number of points to Add. Remove, or Replace. To remove points from a polyline/polygon, specify the number of points you want to remove as a negative number in the number-of-points parameter.

The SetParams method can also be used to automatically remove unnecessary points in Polygons and Polylines. If the SetParams method is called for Polyline or Polygon object and the first two parameters are zero, then points that meet the following conditions will be removed:

a. The X/Y coordinates are the same as the previous point.

b. The Point lies on a line determined by two previous points.

The last parameter of the SetParams method serves both to specify which coordinate system is user, and also whether new points should be added or replaced

Note when modifying points, if the number of points exceeds the number available to be replaced, additional points will be added.

Example – adding points

With MetaDraw
    Dim PointsArray(4)
    PointsArray(0) = 100:  PointsArray(1) = 150
    PointsArray(2) = 300:  PointsArray(3) = 350
    Select Case (Index)
        Case 0   ' Insert 2 new points before the 1st point
            firstpoint = 0
            numpoints = 1
        Case 1   ' Insert 1 new point between 1st and 2nd points
            firstpoint = 2
            numpoints = 1
        Case 2   ' Insert a new point just before last point
            firstpoint = -2
            numpoints = 1
        Case 3   ' Add a new point after last point
            firstpoint = -1
            numpoints = 1
            Label1.Caption = "Points Remaining = " _
               & .SetParams(firstpoint, numpoints, PointsArray, _
                            CRD_LOGIC OR CRD_ADD)
    End Select
End With

Example – moving points

With MetaDraw
    Dim points(4)
    PointsArray(0) = 100:  PointsArray(1) = 150
    PointsArray(2) = 300:  PointsArray(3) = 350
    Select Case (Index)
        Case 0   ' Change 1st point ( = point 0)
            firstpoint = 0
            numpoints = 1
        Case 1   ' Change 2nd and 3rd point
            firstpoint = 1
            numpoints = 2
        Case 3   ' Change last point
            firstpoint = -2
            numpoints = 1
        Case 3   ' Change last point and add 1 additional
            firstpoint = -2
            numpoints = 2
    End Select
    Label1.Caption = "Points Remaining = " _
             & .SetParams(firstpoint, numpoints, PointArray, CRD_LOGIC)
End With

Example – deleting points

' To remove the last point the FirstPoint parameter should be -2,
' The value -1 is used for adding points at end)
With MetaDraw
    Dim points(2)
    Select Case (Index)
        Case 0   ' Remove 1st point ( = point 0)
            firstpoint = 0
            numpoints = -1
        Case 1   ' Remove 2nd point
            firstpoint = 1
            numpoints = -1
        Case 2   ' Remove 1st and 2nd points
            firstpoint = 0
            numpoints = -2
        Case 3   ' Remove last point
            firstpoint = -2
            numpoints = -1
    End Select
    Label1.Caption = "Points Remaining = " _
           & .SetParams(firstpoint, numpoints, PointArray, CRD_LOGIC)
End With


How to use MetaDraw with a database

1. Reading and Writing MetaDraw images to the database

It's easy to Save To, or Load From a database with MetaDraw. The SavePicture and LoadPicture methods provide direct support for database storage

' Save picture to an ADO database field
MetaDraw.SavePicture recADO.Fields("PictureData"), _
        PIC_PICTURE, PICTYPE_DEFAULT
recADO.Update
' Load picture from an ADO database field
MetaDraw.LoadPicture recADO.Fields("PictureData"), _
        PIC_PICTURE, PICTYPE_DEFAULT

When saving to a database, the SavePicture method only writes the picture to the specified field/column. It is still necessary to call the database Recordset.Update method to commit the changes.

2. Associating MetaDraw objects with Database records

Assuming each image is equivalent to a Database Table, Record identifiers may be stored in an ObjectTag. When the user clicks on an object, use the ObjTag property value to find the database record.

Example:

Sub MDraw_Click()
    Criteria = "RecordID = " & MDraw.ObjTag  ' Set the criteria.
    MyRecordset.FindFirst MyCriteria
    Print MyRecordset("PartNumber").Value
    Print MyRecordset("Supplier").Value
End Sub

3. Associating MetaDraw objects with Database fields

Alternatively an ObjTag may hold a FieldName. When the user clicks on an object, read the value of ObjTags("FieldName") and then examine that field in the database to get the desired value.

Example:

Sub MDraw_Click()
    'get data from the field associated with the clicked object.
    FieldName = MDraw.ObjTags("FieldName")
    Value = MyRecordSet(FieldName).Value
End Sub

4. Using MetaDraw as the database

Each image takes the place of a Database Table,
Each graphic object acts as a Record,
Each named ObjTag is a Field for the associated object,
The FindObjectTags method is used as a query to find desired records,
The ObjMove method is used to move from record to record.

Example:

Sub MDraw_Click()
    ' get the relevant data for the selected object
    Record_ID= MDraw.ObjTags("Record_ID")
    Part_Number = MyRecordSet("Part_Number").Value
    Description = MyRecordSet("Description").Value
    Vendor = MyRecordSet("Vendor").Value
    Price = MyRecordSet("Price").Value
    Print Part_Number, Description, vendor, Price
End Sub


How to Vectorize an Image

The MetaDraw Vectorization License option provides support for converting raster images to Vector format. Support is also provided for Noise reduction and Color reduction.

The Vectorization process recognizes regions of uniform color and converts these to independent Polygon objects within MetaDraw. Once an image is converted to vector format, the image and it's multiple individual elements may be further manipulated within MetaDraw either by the end user (dragging, resizing, rotating elements and adding new elements) or programmatically.

Applications:

MetaDraw's Vectorization algorithm is best suited to conversion of images such as "Color Maps", images where there are regions of a single color needing to be converted to polygons. For example scanning a geographic map where each country or state is represented by a different color, and then converting to vectors may result in independent vector objects for each state or country.

MetaDraw's Vectorization is not generally suitable for CAD drawings (development partners/sponsors are invited to discuss options for extending support to CAD and Line Drawings).

Photographs do not generally vectorize well, however they may be suitable for vectorization in certain specific applications after significant color and noise reduction. Possible applications may include recognizing countable objects against a background. Even after color and noise reduction however, vectorized photographs are likely to require very large amounts of memory and long processing times for conversion.

Requirements:

Development use of the BT Vectorization DLL requires purchase of both the MetaDraw 3 license and the optional Vectorization license for MetaDraw 3. When distributing an application using the Vectorization features both the MetaDraw 3 control (MDRAW30.OCX) and the BT Vectorization DLL (BTVECTOR.DLL) must be installed on the end-user machine.

Technical Details:

BT Vectorization DLL provides three principle functions, Color Reduction, Noise Reduction, and Raster to Vector Conversion. It is recommended that all images to be converted to vector format first be reduced to the minimum number of necessary colors (at a maximum of 256 colors) and that noise reduction be performed to eliminate possible erroneous information in the image.

Color Reduction

Before vectorizing an image it is recommended to reduce the number of colors in the image (at a maximum there should be 256 colors before vectorizing). Reducing the number of colors helps to deal with possible errors introduced into an image as a result of scanning as well as reducing the number of vector objects - (each vector object will have at most one color so that two nearly identical colors next to each other may appear to the eye as a single object but will be treated as two seperate objects when vectorizing).

Example :
NumberOfColors = 8
MetaDraw.Picture = MetaDraw.ColorReduction (Picture1.Picture,
                                               NumberOf Colors)

The ColorReduction method reduces the number of color of the given picture (bitmap) to the specified value. The function returns a new picture with a palette of no more than nNumColors colors.

This function applies only to raster images (before conversion to vector format).

In case of errors (DLL not found or non-bitmap image) the function returns a null picture.

Note that nNumColors should be less than 256.

Noise Reduction

Noise Reduction removes stray spots which may be accidentally introduced by processes such as scanning.

MetaDraw considers "Noise" as single colored regions whose size is less than XNoise bitmap pixels in X-direction and YNoise bitmap pixels in Y-directions.

To eliminate noise in the image use the NoiseReduction Method:

Example
    xNoise = 2   ' measured in pixels
    yNoise = 2
    MetaDraw.Picture = MetaDraw.NoiseReduction ( Picture1.Picture, XNoise , YNoise )

This function applies only to raster images (before conversion to vector format).

The function returns the resulted picture or NULL picture in case of errors.

Vectorization

The Vectorize method finds single colored regions within a given raster image and converts them to polygons/polylines. The result of the function is a metafile that contains a set of the corresponding polygons/polylines. The method returns NULL picture in case of errors.

If a resulting polygon / polyline is less than nMinPointSize in pixels using the original scale, that object will be ignored (not added to metafile).

Example
    xNoise = 2   ' measured in pixels
    yNoise = 2
    MetaDraw.Picture = MetaDraw.Vectorize ( Picture1.Picture, MinPointSize)


How to work with embedded controls

MetaDraw supports the embedding of controls within the picture. In general any control that supports the Move method can be inserted into a MetaDraw picture. (Bennet-Tec can not guarantee support for other 3rd party controls)

Controls may be embedded as ordinary children (as with a frame) or as actual parts of the diagram / picture. Such embedded controls may be Scrolled and or zoomed with the picture.

To embed a control in MetaDraw, add the control at design time within MetaDraw as you would add a control to a frame. The EmbeddedControls: method may be called to specify how embedded controls behave.

MetaDraw.EmbeddedControls ( EMB_None )

MetaDraw.EmbeddedControls ( EMB_Scroll )

MetaDraw.EmbeddedControls ( EMB_ScrollShift )

MetaDraw.EmbeddedControls ( EMB_ScrollSize )

Embedded controls may be accessed through the Container.Controls collection

With Metadraw.Container
    X = .EmbeddedControls()
    For iControl = 1 To X
        .Controls( iControl).Top = 0
    Next iControl
End With
Limitations of Embedded Controls

Support for Embedded controls is subject to certain limitations:

  • Embedded controls are not supported under FoxPro programming environment and may not function under certain other environment which do not provide support for ISimpleFrame interface.
  • End-Users may interact with embedded controls in normal manner ( clicking on button, typing in text) only when MetaDraw's EditMode property is set to ED_VIEW.
  • The Align property of an Embedded Control will not for controls contained in MetaDraw.
  • Embedded Controls must be initially placed in MetaDraw at design time.
  • MetaDraw "zooms" embedded controls by resetting the Height and Width properties of all embedded controls. The embedded controls will thus not be truly zoomed – The effect will depend on the type of control ( for instance a listbox may now show more items at the same font when the image is enlarged, but a button control will certainly look like a larger button)
  • Embedded controls are not currently included within the image when printing or saving to file. This support is expected to be added at a later date for users with Subscription License support
  • Embedded controls are not recognized as image elements by Metadraw and can not currently dragged or resized by end-user, or be connected with diagram links. This support is anticipated for later release to be available to users purchasing Subscription License option.


How to Maximize Performance ( speed)

The following tips may be used to maximize performance when using MetaDraw:

Set the EventMask property to avoid triggering events which contain code but are not being used. This can significantly improve performance when the corresponding events contain some code. For example – performance will be greater if the EventMask property is used to disable the Change event while programmatically adding shapes to a picture, than if the Change event is allowed to be triggered and IF or SELECT CASE statements are used to avoid running sections of code intended for use only when the end-user is drawing.

Set the ReDraw property to False while executing code to make a large number of changes to the picture, and reset to True when the changes are complete.

Set the HotSpots property to False while executing code making a large number of changes to the picture, and reset to True ( if needed). This will especially while adding adding many hotspots objects.

It is faster to create a container of grouped objects by first creating an empty container with the AddObject method, opening the container, adding the objects and closing the container, than it is to create the group by first adding the objects and then selecting and grouping them.

The most important technique in improving performance is to define common object attributes as default values by first setting the .Current property to OBJ_DEFAULT and then setting the attributes, rather than to set common attributes for each object after creating the object.


Writing a HotSpot and Painting Application

With MetaDraw you have everything you need to create a simple Windows paint application.

This example illustrates both the use of HotSpots and Setting up End-User Drawings.

Start up Visual Basic and create a new project. Add the MetaDraw control to your form (assume that its name is MetaDraw). Now copy the following code into Declaration section of the form:

Sub Form_Load ()
    Dim i%
    MetaDraw.HotSpots = True: MetaDraw.EventMask = 35
    ' Add text string to the picture
    MetaDraw.AddObject OT_TEXT, 5, 5, 300, 55
    MetaDraw.FontSize = 50: MetaDraw.FontName = "Arial"
    MetaDraw.Text = "  Click mouse on "tools" for painting  "
    MetaDraw.ObjVisible = False
    MetaDraw.TextColor = RGB(0, 255, 255)
    ' Create "painting toolbox"
    '     - eight objects with different colors
    '     - each object is a hotspot used to change the edit mode
    For i% = 0 To 7
        ObjType = I%+1
        X1 = 30+I%*60: Y1 = 100: X2 = 75+i%*60: Y2 = 160
        MetaDraw.AddObject  objType, X1, Y1, X2, Y2
        MetaDraw.ObjHotSpot = OS_CURSOR + OS_HOTSPOT +OS_CLICK
        MetaDraw.FillColor = RGB((i% And 1) * 255, _
                        (i% \ 2 And 1) * 255, (i% \ 4) * 255)
    Next I%
End Sub
Sub MetaDraw_OnHotSpot (X As Integer, Y As Integer, State As Integer)
    MetaDraw.ObjMove = 14
    MetaDraw.ObjVisible = State <> 1
End Sub    ' Shows/Hides the text string

Now just run the program. It's that simple, you've got a picture with hotspot objects. These objects make for a great drawing toolbox. Click any one to select a draw mode.

Note that:

  • The Mouse pointer will change its shape when it is dragging over visible objects;
  • A Hint message will appear when the mouse pointer is upon an object.

OK, add the following code to provide painting support to the application.

Sub MetaDraw_Change (ChangeType As Integer)
    If ChangeType = 2 Then MetaDraw.EditMode = 0
    ' Returns to "Toolbox" mode after object has been added
End Sub

' Select colors and switch to specified edit mode
Sub MetaDraw_HitObject (X As Integer, Y As Integer)
Dim Cl&
MetaDraw.EditMode = MetaDraw.ObjNumber - 1
Cl& = MetaDraw.FillColor
MetaDraw.Current = 4' OBJ_DEFAULT
MetaDraw.FillColor = Cl&
MetaDraw.LineColor = Not Cl& And &HFFFFFF
End Sub

Your application is now complete. You can select the draw mode by clicking the left mouse button on the desired object, and then draw it on the picture. With just a little extra code you can modify this application to support editing, saving and printing the picture.


Using HSEditor for Creating HotSpot Images

The Hotspot Editor – HS Editor is included with the MetaDraw installation kit for use by developers in creating images and adding hotspots without writing much code.

Here is how you can create a hotspot in HS Editor

Set the Initial Image

Load some initial image onto which you intend to add hotspot, or simply create an image within HSEditor by selecting an editing mode from the toolbar and drawing with the mouse

Add Hotspots

First draw the shape ( or select an existing object within the image )

Next click on the Arrow toolbar icon to enter Select mode.

Select the shape with the mouse

Select the menu Object \ HotSpot Info, This will bring up a HotSpot Parameter Dialog box

In the Hotspot parameter dialog box

- check the box that says HotSpot

- if you want the shape to be invisible to the user in View Mode uncheck the Visible box

- if you want to associate some information with this object you can type that information into the HotSpot Info area ( this information will be saved in OBJTag property for the specified shape)

- if you want MetaDraw to automatically open a web page in response to a click on the hotspot you can check the Web URL box and specify a URL

Click OK

Test it Out

Select the menu Tools \ Show Hotspots

If you indicated that the shape should be invisible it should now be hidden

As you move your mouse around you will see the pointer change when over the hotspot. Also in the box next to the Edit button you will see any text you specified as hotspot info. If you click on the hotspot it will bring up the hotspot parameter dialog box and you can again modify the parameters. If you specified a URL for the hotspot it will open Internet Explorer and load the desired web page.

Recognizing HotSpots in Your Applications

Save the image from HS Editor in MetaDraw format (MDP). It is best for you to save in MetaDraw MDP format. MDP format preserves all the information about an image including HotSpts.

Open Visual Basic and place a MetaDraw control and a command button on a form.

The following code will set MetaDraw to respond to Hotspots in your application:

' MetaDraw reacts to hotspots in ED_VIEW mode with HotSpots = True
' In other editmodes, the HitObject method may be called within
' mouse events to identify when mouse is over a hotspot.
Sub Form_Load()
    MetaDraw.EditMode = ED_VIEW
    MetaDraw.HotSpots = True
End Sub
' This event is triggered when user clicks on hotspot
Sub cmdLoadHotSpotPicture_Click()
    MetaDraw.LoadPicture "c:\somepicture.mdp", PIC_PICTURE
End Sub
' This event is triggered when user clicks on hotspot
Sub MDraw_HitObject(ByVal X As Long, ByVal Y As Long)
    MsgBox " you clicked on " & MetaDraw.ObjTag
End Sub
' this event is triggered when user moves into, out of,
' or within hotspot while EditMode = ED_View and Hotspots = True
Sub MDraw_OnHotSpot(ByVal X As Long, ByVal Y As Long, _
                    State As Integer)
    Select Case State
    Case Is = EHS_ENTER
        Text1.Text = "Entered: " & MDraw.ObjTag
    Case Is = EHS_LEAVE
        Text1.Text = "Exited: " & MDraw.ObjTag
    End Select
End Sub


Writing an application for Image Viewing

(Documentation in progress)


Writing an application for Image Annotation

(Documentation in progress)


Writing an application for Label Generation

(Documentation in progress)


Writing an application for Labels with Bar Codes

(Documentation in progress)


Writing an application for Diagramming

(Documentation in progress)


Writing an application for Graphing

(Documentation in progress)


Writing an application for Flow Charting

(Documentation in progress)


Writing an application for Floor Plan Layout

(Documentation in progress)


Writing an application for Data Mapping

(Documentation in progress)


Writing an application for Interactive Graphic Interfaces

(Documentation in progress)


Writing an application for Animation

(Documentation in progress)


Writing an application for Report Generation

(Documentation in progress)


General Information

Class Name

MetaDraw (MetaDrawLIB)

Toolbar Icon


Properties

Properties of the MetaDraw control can be divided into several groups. Properties are presented in the order according to functional grouping. Each property is described in more detail later in this chapter. Note that object attribute properties act upon the object(s) referenced by the .Current property.

More:

Standard properties

Picture information properties

Appearance properties

Mode properties

Import/Export properties

Generic object attributes

Text object attributes

Object Action properties

Coordinates conversion properties

Link Object properties

Internet support properties


Standard properties

About Align BorderStyle DragIcon DragMode


Picture information properties

Property | Description
OrigWidth, OrigHeight | Original picture size
PicLeft, PicTop | Origin of the picture coordinate system
PicWidth, PicHeight | Extent of the picture coordinate system
PicXOfs, PicYOfs | Offset of visible rectangle of picture
PicXSize, PicYSize | Size (width and height) of visible picture
PictureChanged | Was the picture changed
PictureOptions | Some picture's options
ScaleUnits | Determines the measurement units for OrigWidth/Height, PicX/YSize, PicX/YOfs, ClipXXXX properties.
ZoomFactor | Sets the Visible size of the image as a multiple of the Original Size


Appearance properties

Property | Description
AutoScale | Determine how picture should be displayed
BackPicture | Determines the picture that will be used to fill MetaDraw's background
BackPictureAlignment | Determines how the background picture will be displayed
GradientStyle | Determines whether or not to fill the MetaDraw's background with gradient and its style
GridShow, GridAlign | Whether or not to show grid or to align to grid
GridColor | Specifies the color of the alignment grid within MetaDraw
GridWidth, GridHeight | Specify grid size
GridStyle | Determines the presentation style of a Grid within MetaDraw
MarkerColor | Determines colors of selection markers
MarkerSize | Determines a size of selection markers
OpenDraw | Specifies as picture's elements will be drawn
PicBackColor, PicBorderColor | Specify the color to be used as a background inside or outside picture rectangle
Redraw | Whether or not to redraw picture after any change
Repaint | Specifies the repainting method for the picture
ScrollBars | Whether or not to show scrollbars
ScrollCheck | Check boundaries after picture is scrolled or resized
ScrollMouse | Enable or disable picture scrolling by mouse
ScrollKeyboard | Enable or disable picture scrolling by keyboard
ShowInvisible | Whether or not to paint invisible objects
TransparentBackground | Whether or not to draw the MetaDraw's background layer


Mode properties

Property | Description
DropMode | Determines how the control should handle filenames dropped from the Windows Explorer
EditFlags | Specifies mouse functions in selection edit mode
EditMode | Determines a mode for adding a new object by mouse
EventMask | Specifies mask for some events
HotSpots | Determines "hot spot" mode
MouseCursor | Determines the user-defined cursor shape
MousePointer | Determines the cursor shape in the MetaDraw window


Import/Export properties

Property | Description
hDC | Imports or Exports hDC for painting or printing
hPal | Contains a logical palette handle for loaded picture
Picture | Used to import or export a picture in the control
PictureClip | Merge or clip any part of the picture
PictureImage | Determines the "temporary" picture image
PictureType | Type of the picture for export
ExportDC | Specifies an external DC for exporting or printing objects
ExportLeft, ExportTop | Determines X- or Y-coordinate of the origin for exported objects
ExportWidth, ExportHeight | Determines the dimensions of the area on the destination device
ExportOptions | Exporting options
ClipLeft, ClipTop | Determines the origin of the exported area
ClipWidth, ClipHeight | Determines the dimensions of the exported area
JPGQuality | Determines the Compression used for saving JPG images


Generic object attributes

Property | Description
DrawMode | Determines the painting mode
BackStyle | Determines the background style (transparent or opaque)
BackColor | Determines the background color of an object
LineStyle | Determines the line or border style
LineWidth | Determines the line or border width
LineColor | Determines the color of an object's line or border
FillStyle | Determines the method used to fill shape objects
FillPattern | Determines the bitmap pattern to fill a shape object
FillColor | Determines the color used to fill a shape object


Text object attributes

Property | Description
FontBold, FontItalic, FontStrikethru, FontUnderline | Determines font styles for a text object in the following formats: FontBold, FontItalic, FontStrikethru and FontUnderline
FontName | Determines the font used to paint text object
FontOrient | Characters orientation
FontSize | Characters size
FontWidth | Character width
Text | Determines a set of characters (text string) for the Text object
TextColor | Characters color
TextHAlign | Determines the horizontal alignment
TextVAlign | Determines the vertical alignment
TextStyle | Determines the text style (standard, multi-line)


Object Action properties

Property | Description
Action | Determines the action on specified objects
Current | Specifies the current object or the group of the objects
ObjCount | Counts the number of specified objects
ObjNumber | object's order number
ObjHotSpot | Toggles the "hot spot" flag for specified object
ObjMove | Move Current pointer to the specified object
ObjOpened | Opens the specified object (container)
ObjLeft, ObjTop, ObjRight, ObjBottom | Return the object's logical coordinates
ObjSelected | Returns/Toggles selection status
ObjTag | Determines the object information string
ObjType | Returns the object type, also used to convert to a new object type
ObjVisible | Returns/Toggles visible status of the specified object
ObjStatus | Determines the status flags of the object
ObjTags | Determines the object named tags
ObjRotation | Determines the rotation angle
ObjURL | Determines the URL attached to the object


Coordinates conversion properties

Property | Description
ClientHeight | Return the height of picture box client area
ClientWidth | Return the width of picture box client area
ClientToLogicX, ClientToLogicY | Convert point from client box pixels to logical picture coordinates
LogicToClientX, LogicToClientY | Convert from logical coordinates to client pixels


Link Object properties

Property | Description
LinkFlags | Determines direction and fill for link terminators.
LinkLength/LinkWidth | Determines the size of Link terminators
LinkObject | Determines which objects are connected to a link
LinkStyle | Determines shape of link terminators.
LinkLabel | Assigns or retrieves a text label to/from the Link, Line, or Dimension Line object
LinkSymbolColor | Sets/returns the color of the specified link symbol


Internet support properties

Property | Description
WebTargetFrame | Determines the frame name
WebURLBase | Determines the base of the object URLs
WebNavigate | Navigates the web browser to a document specified by a URL.
WebGoBack, WebGoForward | Navigates to the Previous or Next item in the history list
ObjURL | Determines the URL attached to the object


Events

MetaDraw can trigger the following events. Non-standard events are in bold face:

Event | Description
Change | Occurs when changes are made to the Picture (object)
Click | Occurs when the user presses and then releases a mouse button over the control
DblClick | Occurs when the user double-clicks a mouse button over the control
DragDrop | Occurs when a drag-and-drop operation is complete
DragOver | Occurs when a drag-and-drop operation is in progress
DropFile | Occurs when files are dropped from Windows Explorer
Export | Occurs when an object is exporting to another Device Context (e.g., during printing)
HitObject, HitObjectDouble | Occurs when the user clicks the left mouse button over an object
GotFocus | Occurs when the control receives the focus
KeyDown | Occurs when the user presses a key while the control has the focus
KeyPress | Occurs when the user presses a key
KeyUp | Occurs when the user releases a key while the control has the focus
LostFocus | Occurs when the control loses the focus
MouseDown | Occurs when the user presses a mouse button over the control
MouseMove | Occurs when the user moves the mouse over the control
MouseUp | Occurs when the user releases a mouse button over the control
OnHotSpot | Occurs when the user moves the mouse over a tagged object
Scroll | Occurs when the control is scrolled or resized.


Methods

MetaDraw supports the following predefined VB methods. Methods that have a special implementation are in bold face:

Method | Description
AboutBox | Displays a Dialog box identifying MetaDraw version and license s/n
Clear | Clear the picture (delete all elements)
Drag | Begins, ends, or cancels dragging controls
Move | Moves a MetaDraw control
Refresh | Repaint or update picture in the control
SetFocus | Sets the focus to MetaDraw control
Zorder | Places the control at the front or back of the Z-order
AddObject | Add a new object into MetaDraw
AddObjectDefault | Create a new object with default boundaries
GetBounds | Retrieves object(s) boundaries
GetParams | Retrieves object's additional parameters
LoadPicture | Loads pictures from an external file
MoveObjects | Changes position of specified objects
ObjectsHitTest | Finds objects which are located under specified coordinates
RemoveObject | Deletes specified object(s)
SavePicture | Saves MetaDraw's pictures to a file
SetBounds | Sets new object boundaries
SetParams | Sets or replaces object's points.


Detailed Specifications

The following section contains an alphabetized listing with descriptions, of all MetaDraw properties, events, methods and functions.

Note the meanings of the following markers used in this section:

The property marked this sign is Read-Only.
The property marked this sign is Write-Only.
The property marked this sign is available only at run-time mode. You can change or read it only using Visual Basic code statements. This property will not appear in Visual Basic properties window.

More:

About Property

AboutBox Method

Action Property

AddObject Method

AddObjectDefault Method

Align Property

ArrangeObjects method

AutoScale Property

BackColor Property

BackPicture, BackPictureAlignment Properties

BackStyle Property

BorderStyle Property

Change Event

ChangeLogicalCoords Method

ChooseColor Method

Clear Method

Click Event

ClientHeight, ClientWidth Properties

ClientToLogicX, ClientToLogicY Properties

ClipLeft, ClipTop, ClipWidth, ClipHeight Properties

ColorReduction Method

CopyToClipboard Method

CreateImageMap Method

CreateLink Method

Current Property

DblClick Event

Drag Method

DragDrop, DragOver Events

DragIcon Property

DragMode Property

DrawMode Property

DropFile Event

DropMode Property

DXFScaleFactor Property

EditFlags Property

EditMode Property

EmbeddedControls Method

Enabled Property

EventMask Property

Export Event

ExportDC Property

ExportLeft, ExportTop, ExportHeight, ExportWidth Properties

ExportOptions Property

FillColor Property

FillPattern Property

FillStyle Property

FindObjectTags Method

FontBold, FontItalic, FontStrikethru, FontUnderline Properties

FontCharSet Property

FontName Property

FontOrient Property

FontSize Property

FontWidth Property

GetBounds Method

GetGrayScaleValue Method

GetParams, GetParamsEx Methods

GotFocus Event

GradientStyle Property

GridAlign Property

GridColor Property

GridHeight, GridWidth Properties

GridShow Property

GridStyle Property

hDC Property

Height Property

HelpContextID Property

HitObject, HitObjectDouble Events

HitSensitivity Property

HotSpots Property

hPal Property

hWnd Property

Index Property

JPGQuality Property

KeyDown, KeyUp Events

KeyPress Event

Left, Top Property

LineColor Property

LineStyle Property

LineWidth Property

LinkFlags Property

LinkLabel Property

LinkLength, LinkWidth Properties

LinkObject Property

LinkStyle Property

LinkSymbolColor Property

LoadData Method

LoadPicture Method

LoadPictureEx Method

LoadPictureFromFile Method

LogicToClientX, LogicToClientY Properties

LostFocus Event

MarkerColor Property

MarkerSize Property

MDDataObject Object

MDDataObject.Clear Method

MDDataObject.GetData Method

MDDataObject.GetFormat Method

MDDataObject.SetData Method

MDDataObject.GetPicture Method

MDDataObject.SetPicture Method

MDDataObject.Files Property

MDPicture Property

Modifications Property

MouseCursor Property

MouseDown and MouseUp Events

MouseMove Event

MousePointer Property

MouseWheel Event

Move Method

MoveObjects method

Name Property

NoiseReduction Method

ObjBottom, ObjLeft, ObjRight, ObjTop Properties

ObjCount Property

ObjectHitMarker Method

ObjectsInRect Method

ObjectsHitTest Method

ObjectsOverlappedBy Method

ObjHotSpot Property

ObjLeft Property

ObjMove Property

ObjLinkCount Property

ObjLinks Property

ObjNumber Property

ObjOpened Property

ObjRight Property

ObjResolution Property

ObjRotation Property

ObjSelected Property

ObjShadow, ObjShadowColor, ObjShadowOfsX,Y Properties

ObjStatus Property

ObjTag Property

ObjTags Property

ObjTagsCount Property

ObjTagsName Property

ObjTagsValue Property

ObjTop Property

ObjType Property

ObjURL Property

ObjVisible Property

OLECompleteDrag Event

OLEDrag Method

OLEDragDrop Event

OLEDragMode Property

OLEDragOver Event

OLEDropMode Property

OLEGiveFeedback Event

OLESetData Event

OLEStartDrag Event

OnHotSpot Event

OpenDraw Property

OrigHeight, OrigWidth Properties

Parent Property

PasteFromClipboard Method

PicBackColor, PicBorderColor Properties

PicLeft, PicTop, PicWidth, PicHeight Properties

Picture Property

PictureTarget Property

PictureChanged Property

PictureClip Property

PictureImage Property

PictureOptions Property

PictureType Property

PicWidth Property

PicXOfs, PicYOfs Properties

PicXSize, PicYSize Properties

Redo Method

ReadImageMap Method

Redraw Property

Refresh Method

RemoveObject Method

Repaint Property

RotateObjects Method

RotatePicture Method

SaveData Method

SavePicture Method

SavePictureEx Method

SavePictureToFile Method

ScaleUnits Property

Scroll Event

ScrollBars Property

ScrollCheck Property

ScrollKeyboard Property

ScrollMouse Property

SetBounds Method

SetFocus Method

SetLinkPoint Method

SetParams Method

ShowInvisible Property

TabIndex Property

TabStop Property

Tag Property

Text Property

TextColor Property

TextStyle Property

TextHAlign Property

TextVAlign Property

Top Property

TransparentBackground Properties

Undo Method

UndoLevels Property

UndoGrouping Property

Vectorization Method

Version Property

Visible Property

WebGoBack, WebGoForward methods

WebNavigate method

WebTargetFrame Property

WebURLBase Property

Width Property

ZoomCentering Property

ZoomFactor Property

ZOrder Method


About Property

Description

At design time, double-click this property in the property window to popup the About box that shows version, copyright and registration (user name, serial number, license flags) information. The About property does not carry any value and is not available at runtime.

You can also receive the version of current OCX at run time mode using the Version property.


AboutBox Method

Calling the AboutBox method causes MetaDraw to display a dialog box identifying MetaDraw, the version in use, the license serial number, and Bennet-Tec as the copyright holder on MetaDraw.


Action Property

Description

Starts specified action on the selected objects, or container, specified in the Current property.

Usage

[form.]MDraw.Action = action%

Settings

The Action property settings are:

Constant | Value | Description
ACT_GROUP | 0 | Create a container grouping all currently selected objects. More than one object must be selected, and the Current property must be set to OBJ_SELECTED (= 2).
ACT_UNGROUP | 1 | Ungroup container (or all selected containers). After this action all objects from the container(s) become selected.
ACT_SENDBACK | 2 | Send selected objects to the back of all other objects.
ACT_MOVEFRONT | 3 | Bring selected objects to the front of all other objects.
ACT_ONEDOWN | 4 | Move object(s) below previous object.
ACT_ONEUP | 5 | Move object(s) on top of next object.
ACT_FLIPHORZ | 6 | Flip object(s) horizontally.
ACT_FLIPVERT | 7 | Flip object(s) vertically.
ACT_ROTATELEFT | 8 | Rotate object in a clockwise direction.
ACT_ROTATERIGHT | 9 | Rotate object by a counter clockwise direction.
ACT_IMAGEINSERT | 10 | Insert picture specified in the PictureImage property to the open container.
ACT_IMAGECOPY | 11 | Copy object(s) specified by the Current property into PictureImage.
ACT_IMAGEPICTURE | 12 | Reset's the Picture property using the picture specified by the PictureImage property.
ACT_IMAGESWAP | 13 | Swap pictures between the Picture and PictureImage properties. This action works only when pictures are defined both in Picture and PictureImage.
ACT_DUPLICATE | 14 | Duplicate object(s) whose handle(s) is (are) specified in the Current property. MetaDraw adds the new object(s) at the top of objects stack. If the action is applied to selected objects, each selected object will be duplicated and it becomes selected.

Remarks

The Current property specifies the object(s) to be affected by the action. After the specified action is done the Current property contains one of the following values:

Action | Value of the Current property
ACT_GROUP | Handle of the new container.
ACT_UNGROUP | OBJ_SELECTED (all selected objects). After this action, ungrouped objects become selected.
ACT_IMAGEINSERT | Handle of the inserted object (or container).
ACT_IMAGEPICTURE, ACT_IMAGESWAP | OBJ_CONT_MAIN (reserved handle of the main container).
ACT_DUPLICATE | Handle of the new object or OBJ_SELECTED if several (selected) objects have been duplicated.

The Current property is not changed after one of the following actions: ACT_SENDBACK, ACT_MOVEFRONT, ACT_ONEDOWN, ACT_ONEUP, ACT_FLIPHORZ, ACT_FLIPVERT, ACT_ROTATELEFT, ACT_ROTATERIGHT, and ACT_IMAGECOPY.

Note: Objects can only be rotated 90° per action. To rotate an object 180°, the action must be applied twice. In MetaDraw you can use the ObjRotation property to rotate objects on any angle.

Data Type

Integer (Enumerated)

See also

Objects selecting, Changing object's attributes, Current property, PictureImage property


AddObject Method

Description

This method adds a new object to the current picture in the MetaDraw control box.

Syntax

MDrawPro.AddObject object_type%, left&, top&, right&, bottom&

Settings

Parameter | Description
object_type% | Type of new object (see table below for listing of OT_xxxx constants)
left&, top& | The left-top corner for the new object.
right&, bottom& | Coordinates of the right-bottom corner for the new object.

The following Object Type constants can be used to specify what type of object is to be added.

Constant | Value | Description
OT_CONTAINER | 0 | Container (group of objects).
OT_LINE | 1 | Line
OT_RECTANGLE | 2 | Rectangle
OT_ROUNDRECT | 3 | Rounded rectangle
OT_ELLIPSE | 4 | Ellipse (circle)
OT_ARC | 5 | Arc
OT_PIE | 6 | Pie (sector)
OT_CHORD | 7 | Chord
OT_POLYLINE | 8 | Polyline
OT_POLYGON | 9 | Polygon
OT_TEXT | 10 | Text
OT_IMAGE | 12 | Image (picture held by the PictureImage property)
OT_BEZIER | 14 | Bezier curve
OT_FLOODFILL | 19 | Floodfill
OT_DIMLINE | 22 | Dimension line
OT_TRIANGLE | 30 | adds a polygon initialized as a Triangle
OT_DIAMOND | 31 | adds a polygon initialized as a Diamond
OT_PENTAGON | 32 | adds a polygon initialized as a Pentagon
OT_STAR | 33 | adds a polygon initialized as a Star
OT_HEXAGON | 34 | adds a polygon initialized as a Hexagon
OT_OCTAGON | 35 | adds a polygon initialized as a Octogon

Remarks

A new object or container will be added to the content of the current open container.

After adding an object, the Current property will be automatically set to contain the handle of the new object or container.

Newly added objects are NOT automatically selected. You may however set the ObjSelected property to select the object after adding it.

The new object will be created with MetaDraw's default attributes. Default attributes for the picture can be changed when the Current property is OBJ_DEFAULT. You can also change attributes (line width, fill color, …) of the object immediately after it has been created by the AddObject method.

The four coordinate parameters in this method determine the boundaries of the new object in logical coordinates and should be within the range from (.PicLeft, .PicTop) to (.PicLeft + .PicWidth, .PicTop + .PicHeight ). The object will be created with default data. The boundaries of the new object can be changed later using the SetBounds method. Use the SetParams method to change additional parameters of the object: add new points to Polyline/Polygon, change starting and ending points in Arc/ Chord/ Pie, change rounded corners for Rounded Rectangle.

Using the AddObject method with OT_TEXT will create an empty Text object. The text for this object can then be set using the Text property. In case of OT_TEXT, the text object is positioned as specifed by the text alignment properties, TextVAlign and TextHAlign, with respect to the object's boundaries. The size of a new text object may depend on the coordinates specified as well as the FontSize, and TextStyle properties.

Where the TextStyle = TXT_STANDARD, the font size will be determined by the specified boundaries (top&, bottom& ), unless the specified height is 0, in which case the the default fontsize will be used and the object height will be adjusted accordingly. The object width will be determined by the text.

Where TextStyle = TXT_BOUNDED, the font size and object height will be set as with standard text objects, but the character spacing will be adjusted to fit within the specified boundary width ( left&, right&).

Where TextStyle = TXT_BOXED, the text is presented according to it's default FontSize, but the overall object height – the height of the surrounding box - will be set to whichever is larger - either the height specified by the fontsize, or the height specified by the coordinate parameters (top&, bottom& ).

Where TextStyle = TXT_MULTILINE, the text is presented according to it's default FontSize, but the object height and width will be increased as required to accommodate the text.

When the object_type% is OT_IMAGE, calling AddObject with zero height and width ( parameters left& = right& and top& = bottom&), inserts the image determined by the PictureImage property into the open container at the image's default size. The new object will be added either as a single object (ObjType will return 11 = OT_BITMAP) or as a container (0=OT_CONTAINER) if the picture in the PictureImage property is itself a metafile containing several objects.

Newly added containers ( object groups) are initially closed and will have zero width and height regardless of the specified coordinate parameters. To add object to a new container it should first be opened by using the ObjOpened property. After closing the container it's position and size will be determined by the minimum bounding rectangle surrounding the objects grouped by the container.

It is not possible to add a link object using the AddObject. To create links between two objects use the CreateLink method.

Example

The following example creates a container, adds objects within the container, and then closes the container:

With MetaDraw1
    .AddObject OT_CONTAINER, 0, 0, 0, 0
    .ObjOpened = True
    .AddObject OT_RECTANGLE, 100,120,300,220
    .AddObject OT_ELLIPSE, 33,60, 120, 280
    .ObjMove = MOVE_CONT_OPENED
    .ObjOpened = False
End With

The following code will insert a bitmap at it's original size in a specified location:

MetaDraw1.LoadPicture "c:\somepic.bmp", PIC_PICTUREIMAGE
MetaDraw1.AddObject OT_IMAGE, 125, 200, 125, 200

The following code creates a text object inside dotted frame:

MetaDraw1.AddObject OT_TEXT, 10, 10, 10, 10
MetaDraw1.Text = "First Line"
MetaDraw1.GetBounds l&, t&, r&, b&, 0
MetaDraw1.AddObject OT_RECTANGLE, l&, t&, r&, b&
MetaDraw1.FillStyle = FS_TRANSPARENT
MetaDraw1.LineStyle = PS_DOT

An alternative way to accomplish the same effect is to use Boxed TextStyle:

MetaDraw1.AddObject OT_TEXT, 10, 10, 10, 10
MetaDraw1.Text = "First Line"
MetaDraw1.TextStyle = TXT_BOXED
MetaDraw1.FillStyle = FS_TRANSPARENT
MetaDraw1.LineStyle = PS_DOT

See also

Creating a new object, PictureClip property, PictureImage property


AddObjectDefault Method

Description

Adds a new object with default boundaries into the current picture in the MetaDraw control box.

Syntax

MDraw.AddObjectDefault object_type%

Settings

Parameter | Description
object_type% | Type of the object (see the ObjType property for listing of OT_xxxx constants)

Remarks

The functionality of this method is similar to the functionality of the AddObject method, except that you don't need to specify the object's boundaries. The new object will have zero boundaries or the boundaries based on the size of the inserted image (if the object_type% parameter is OT_IMAGE) or based on the text size (if object_type% is OT_TEXT). Object boundaries can be changed later using the SetBounds method.

Note: This method is useful for creating a new container or inserting image that is kept in the PictureImage property.

See also

Creating a new object, AddObject method, PictureClip property, PictureImage property


Align Property

Description

This standard property determines whether MetaDraw can appear in any size anywhere on a form, or whether it will be forced to the top or bottom of the form and automatically sized to fit the form's width (or height for MetaDraw).

Usage

[form.]MDraw.Align = setting%

Settings

The Align property settings are:

Setting | Value | Description
None (default) | 0 | Size and location can be freely changed.
Top | 1 | The control is aligned at the top of the form and its Width is equal to the form's ScaleWidth property.
Bottom | 2 | The control is aligned at the bottom of the form and its Width is equal to the form's ScaleWidth property.
Left | 3 | The control is aligned at the left of the form and its Height is equal to the form's ScaleHeight property.
Right | 4 | The control is aligned at the right of the form and its Height is equal to the form's ScaleHeight property.

Data Type

Integer (Enumerated)

See also

Align property in the Microsoft Visual Basic Language Reference.


ArrangeObjects method

!!! This feature requires MetaDraw Diagram Arrange License Option !!!

Description

Calling the ArrangeObjects method repositions objects within a diagram to optimize layout of linked objects, or to lay unlinked objects in rectangular grid.

Declaration:

Function ArrangeObjects Ê
Ä (ByVal ContainerHandle As Long, Ê
Ä ByVal Left As Long, ByVal Top As Long, Ê
 Ä ByVal Right As Long, ByVal Bottom As Long, Ê
 Ä ByVal MinX As Long, ByVal MinY As Long, Ê
 Ä ByVal Mode As Integer Ê
 Ä [, ByVal Param As Integer]) As Long

Syntax

Return_Code = MDraw.ArrangeObjects ( _OBJ_CONTAINER, _
        TargetLeft, TargetTop, TargetRight, TargetBottom, _
        MinX, MinY, Mode, 0 )

Parameters:

The ArrangeObjects method uses these arguments:

Argument | Description
ContainerHandle | a MetaDraw handle identifying the container holding the objects which should be arranged. The following reserved handles can be used:
 | Constant |  | Value | Description
 | OBJ_CONTAINER |  | 1 | Arrange all objects which are within the current open container.
 | OBJ_SELECTED |  | 2 | Arrange only selected objects within the current open container.
 | OBJ_CONT_MAIN |  | 5 | Arrange all objects in main container.
 | NOTE: Only objects directly contained within the specified container will be arranged. Sub-Containers (groups within the specified container) are treated as single objects and their contents are not internally arranged.
Left, Top, Right, Bottom | parameters defining the bounding rectangle within which the objects should be arranged (in global logical units).
MinX, MinY | Specifies the desired minimum distance between objects boundaries in horizontal/vertical direction (in global logical units).
Mode | Determines the arrangement mode. Possible values are:
 | Value | Description
 | -1 | Rectangular Arrangement - Arrange objects independently of any links between them. Objects will be moved to minimize overlapping of their bounding rectangles.
 | 0 | UnBound Link Arrangement – Arranges objects according to the links between them. MetaDraw will attempt to move objects to minimize crossing of links, and to avoid overlap of objects' bounding rectangles. In UnBound mode objects may be moved anywhere within the MetaDraw image – the Right and Bottom parameters of the function call are ignored.
 | 1 | Bound Link Arrangement - The same as UnBound mode (0), except that movement of objects will be restricted to the specified rectangular area.
nParam | (valid when Mode = -1 only) This parameter determines different styles of rectangles location. Possible values in the range: 0 - 100.

Returns

The function returns the number of objects that have been moved or -1 in case of errors.

Remarks

Use of this method requires optional Diagram Arrange license option.

The Diagram Arrange library allows MetaDraw to rearrange objects within the overall image in such a way as to minimize overlapping straight links and to lay out the diagram in an "organized" fashion. Objects which are not linked may also be layed out in a rectangular grid fashion using this function.

This method does NOT apply to segmented links.

All embedded containers are single objects. Objects within containers ( grouped objects) are not rearranged unless ObjContainerHandle points at their immediate container

All objects are represented by their bounding rectangles.

Note: The Diagram Arrange library algorithm is proprietary to Bennet-Tec. Be aware that each image may result in different Arrangements, that such arrangements are the result of proprietary calculations and are not subject to negotiation or standards of what might be better or worse. Bennet-Tec does not guarantee that our "optimized" layouts will fit with your application's definition of an optimized layout. If you are interested in modified arrangements Bennet-Tec can take on sponsored (paid) development projects to tune the layout to your needs.

See also

Object grouping, .Current property


AutoScale Property

Description

Determines whether the picture image is automatically scaled to fit in the display window, or if the original picture size is preserved.

Usage

[form.]MDraw.AutoScale = setting%

Settings

The AutoScale property settings are:

Setting | Value | Description
SCALE_NONE (default) | 0 | The values of the PicXSize, PicYSize properties are set according to the original picture size only when the picture is loaded and are not changed automatically afterwards.
SCALE_RESIZE | 1 | When the control is resized, PicXSize and PicYSize are set to the width and height of the control (without border) accordingly.
SCALE_FIT | 2 | The PicXSize, PicYSize properties are immediately set such that the image fits in the display window of the MetaDraw control (preserving the picture's aspect ratio). These properties will be updated if control is resized.
SCALE_ORIG | 3 | The PicXSize, PicYSize properties are immediately set to the actual size of the current picture. After the assignment, the control resets the value of the AutoScale property to 0 (SCALE_NONE). The PicXOfs, PicYOfs properties are immediately set to zero.

Remarks

The setting SCALE_ORIG (3) is more like a command rather than a setting, but it is an easy way to display the picture with its original sizes. The PicXOfs, PicYOfs, PicXSize, PicYSize properties can be changed manually only if AutoScale is SCALE_NONE (0).

SCALE_NONE (0) | SCALE_RESIZE (1) | SCALE_FIT (2)
The visible picture position and sizes are set manually using PicXOfs, PicYOfs and ZoomFactor or PicXSize, PicYSize properties. | The picture fills the whole MetaDraw window area. It can be distorted if the width/height ratio is not the same as the OrigWidth/OrigHeight ratio. | The area that is not covered by the picture will fill with color specified in the PicBorderColor property.

Data Type

Integer (Enumerated)

See also

Zooming and Scrolling pictures Zooming and Scrolling pictures , PicXSize, PicYSize, and ZoomFactor properties PicXSize, PicYSize Properties


BackColor Property

Description

Determines the background color of objects other than bitmaps. The BackColor property also defines a transparent color for transparent bitmap objects.

Usage

[form.]MDraw.BackColor [= color_expression&]

Remarks

The BackColor is used to fill a text object's background, gaps in non-solid lines, and the space between hatches in a hatched brush.

Note: For objects other than bitmaps the BackColor property is ignored if the BackStyle property is zero (BS_TRANSPARENT).

Data Type

Long (Color)

See also

Changing object's attributes, BackStyle property


BackPicture, BackPictureAlignment Properties

Description

The BackPicture property determines what graphic will be displayed on MetaDraw's background. The BackPictureAlignment property specifies how the picture specified in the BackPicture property will be displayed on the background.

The Background picture is distinct from the Picture being edited (it can not be selected, resized, dragged or modified by the end-user regardless of the setting of the EditMode property.

Syntax

[form.]MDraw.BackPicture [ = <Picture Object>]

[form.]MDraw.BackPictureAlignment [ = Enum%]

Settings

The BackPictureAlignment property settings are:

Constant | Value | Description
BPALG_LEFTTOP | 0 | Image is left/top aligned.
BPALG_LEFTMIDDLE | 1 | Image is left/middle aligned.
BPALG_LEFTBOTTOM | 2 | Image is left/bottom aligned.
BPALG_CENTERTOP | 3 | Image is right/top aligned.
BPALG_CENTERMIDDLE | 4 | Image is right/middle aligned.
BPALG_CENTERBOTTOM | 5 | Image is right/bottom aligned.
BPALG_RIGHTTOP | 6 | Image is center/top aligned.
BPALG_ RIGHTMIDDLE | 7 | Image is center/middle aligned.
BPALG_ RIGHTBOTTOM | 8 | Image is center/bottom aligned.
BPALG_STRETCH | 9 | Image is stretched to fit the drawing area.
BPALG_TILE | 10 | Image is tiled in the drawing area.

Remarks

In all alignment modes, except BPALG_STRETCH, MetaDraw draws the background image with its original size which may be larger or smaller than the drawing area.

The background set with the BackPicture property does NOT zoom or scroll with the MetaDraw picture, unless the PICOPT_PICTUREBACKGROUND flag is set in the PictureOptions property. There are several flags in the PictureOptions property that can also affect the background picture (see the PictureOptions property description).

Similarly the background set with the BackPicture property is not exported ( will not Save, Print, or be included as part of Picture read by Picture property) unless the EXOPT_BACKGROUND flag is included in the ExportOptions property.

Supported picture types that can be assigned to the BackPicture property are: BMP, ICO, WMF, EMF, JPG, PNG. MetaDraw's LoadPicture method, with a destination parameter of PIC_BACKPICTURE, can be also used to assign a picture as a background picture. The LoadPicture method also supports other formats recognized by MetaDraw, but which can not be directly assigned to the BackPicture property (GIF, DXF, MDP). Support of TIFF format background may be achieved using the ClearEdge add-on to MetaDraw.

The standard BackPicture is not subject to clipping or zooming when exporting the image to a printer or other device context.

Data Type

Picture | for BackPicture
Integer (Enumerated) | for BackPictureAlignment

See also

LoadPicture method, PictureOptions property


BackStyle Property

Description

Determines whether the object's border or background is transparent or opaque.

Usage

[form.]MDraw.BackStyle [= setting%]

Settings

The BackStyle property settings are:

Setting | Value | Description
BS_TRANSPARENT | 0 | Background is not changed.
BS_OPAQUE | 1 | The color specified by the BackColor property is used to fill in the background of a text object's, gaps in non-solid lines, and the space between hatches in a hatched brush.

Remarks

This property may be applied to bitmaps to draw a bitmap with transparent color. In that case the BackColor property determines the color which will be interpreted as a transparent area.

Data Type

Integer (Enumerated)

See also

Changing object's attributes, BackColor property


BorderStyle Property

Description

This standard property determines the border style for the MetaDraw control.

Usage

[form.]MDraw.BorderStyle = setting%

Settings

The BorderStyle property settings are:

Setting | Description
0 | No border.
1 | Fixed single border

Data Type

Integer (Enumerated)

See also

BorderStyle property in the Microsoft Visual Basic Language Reference.


Change Event

Description

Occurs when the picture in the MetaDraw box is changed by adding objects, moving objects, deleting objects, changing properties or number of objects selected.

Syntax

Sub MDrawPro_Change ([Index As Integer,] ByVal ChangeType As Integer)

Remarks

The Change event occurs after any change was performed or after last group operation. For example, if you click the mouse on an unselected object, that object become selected, the previously selected objects are dropped from selection, and the Change event occurs with the ChangeType parameter set to CHG_SELECTION (1).

Only one event will be triggered for each action, regardless of how many objects were affected – for instance if multiple objects are deselected at one time, or a container / group holding multiple objects is deleted.

The type of change is passed in the ChangeType parameter. This parameter can have the following values:

Constant | Value | Description
CHG_NONE | 0 | Nothing was changed.
CHG_SELECTION | 1 | Selection was changed for one or more objects.
CHG_OBJECTADD | 2 | An object was added. The Current property contains handle of the added object.
CHG_OBJECTMOVE | 3 | One or more objects were moved.
CHG_OBJECTRESIZE | 4 | An object was resized.
CHG_OBJECTOPEN | 5 | An object or container was opened.
CHG_OBJECTCHANGE | 6 | Object's attributes were changed.
CHG_OBJECTDELETE | 7 | One or more objects were deleted.
CHG_OBJECTGROUP | 8 | Objects were grouped.
CHG_OBJECTUNGROUP | 9 | Container(s) was (were) ungrouped.
CHG_OBJECTROTATE | 10 | An object was rotated.

After entering this event, the Current property contains the handle of the added object (the ChangeType parameter is CHG_OBJECTADD) or the handle of the object whose parameters were changed. If changes were applied on several selected objects, the Current property is OBJ_SELECTED.

It is recommend to avoid any manipulations of the MetaDraw picture within the Change event, as such changes may lead to recursive calls of this event and turn the application into infinite looping.

If ChangeType is CHG_OBJECTDELETE the Current property is OBJ_NULL.

Note: This event can be masked in the EventMask property for different values of the ChangeType parameter.

See also

Editing objects, Selecting objects, Current property, EventMask property


ChangeLogicalCoords Method

Description

This method changes the range of the logical coordinate system for the main picture ( and optionally the size of the picture), while retaining the coordinate locations of existing objects.

Declaration

Function ChangeLogicalCoords ( _ Ê
Ä ByVal newPicLeft As Long, ByVal newPicTop As Long, _ Ê
Ä ByVal newPicWidth As Long, ByVal newPicHeight As Long _ Ê
Ä ByVal crdType As Integer]) As Long

Syntax

[form.]MDraw.ChangeLogicalCoords left&, top&, width&, height&, crdType

Parameters

The first four parameters, NewPicLeft, newPicTop, newPicWidth and newPicHeight, are used to specify the internal coordinate system.

The last parameter, crdType%, is a bit flag value. It may be set by combining (Logical OR) values from the table below:

Constant | Value | Description
CRD_PIXELS | 4 | Set this flag to specify coordinates in pixels
CRD_DONTREMOVE | 0x1000 | Set this flag to retain objects located outside the new coordinate system ( outside the new boundaries of the picture). If this flag is not set, such objects are automatically removed. This setting is NOT recommended for most applications.
CRD_PARTLY | 0x2000 | Set this flag to remove objects if any part of them lies outside new picture boundaries. This is a recommended setting for most applications.
CRD_SAMEORIG | 0x4000 | Set this flag to retain the existing image size. In this case only the Logical Coordinate System is changed and OrigWidth and OrigHeight settings are unchanged. If this flag is NOT set, the actual unzoomed size of the picture will be increased/decreased in proportion to the changes in PicWidth and PicHeight.

Returns

The ChangeLogicalCoords method returns the number of objects that have been removed (or which would be removed if CRD_DONTREMOVE is specified).

Remarks

The ChangeLogicalCoords method may be used to change the range of logical coordinates, and optionally the size, of a picture without destroying the objects which already exist. Objects inside the picture retain the same coordinates, but you can add additional space or remove unused drawing space without recreating the whole picture.

If either the newPicWidth or newPicHeight parameters are zero, MetaDraw calculates these values automatically to maintain the picture's current aspect ratio.

If the CRD_DONTREMOVE flag is set in crdType% parameter, all objects that are not inside new picture boundaries will be removed.

Objects partly located in new picture boundaries will be kept unless the CRD_PARTLY flag is set.

Note: When CRD_SAMEORIG is used picture may become non-proportional (resolution by X- and Y- direction are not the same). This can result in undesirable presentation – especially of Text objects. When using this flag, try to increase PicWidth and PicHeight by the same proportion.

Example

' Increase the width of the image by 25 %
Removed = MDraw.ChangeLogicalCoords ( MDraw.PicLeft, MDraw.PicTop,  _
      1.25 * MDraw.PicWidth, 1.25 * MDraw.PicHeight, 0)
' Change the range of coordinate system without changing
' the actual size of the image

Removed = MDraw.ChangeLogicalCoords ( 0, 0, 1000, 1000, CRD_SAMEORIG )

See Also

Picture coordinates


ChooseColor Method

Description

The ChooseColor method presents the end-user with a standard ColorDialog box.

Declaration

Function ChooseColor ( ByVal clDefault As Long) As Long

Syntax

Return& = [form].MDraw.ChooseColor (clDefColor&)

Parameters

The clDefColor parameter is a long integer determines the RGB default color.

Returns

The Return value is a long integer - either the chosen RGB color (if the "OK" button is clicked) or -1 ( if the "Cancel" button is clicked).

Example

MetaDraw.AddObject, OT_ELLIPSE, X1, Y1, X2, Y2
Color& = MetaDraw.ChooseColor ( &HFFFF00 )
If color& <> -1 Then MetaDraw.LineColor =Color&


Clear Method

Description

Destroy (erase) the current picture in the MetaDraw control box.

Syntax

MDraw.Clear

Remarks

After this method is invoked, all objects in the current picture will be deleted, but the picture coordinate properties do not change. To fully destroy the picture, use the following code:

[form].MDraw.PicWidth = 0    ' or
[form].MDraw.PicHeight = 0

Calling this method also resets the Current property to OBJ_DEFAULT ( = 4) at which point setting object attributes ( such as LineColor etc) will set defaults for objects added later.

See also

Creating a New picture, .Picture property


Click Event

Description

This standard event occurs when the user presses then releases a mouse button over a MetaDraw control.

Syntax

Sub MDraw_Click ([Index As Integer])

Remarks

The Click event is triggered after MouseDown event, but before MouseUp event.

To trap events over specific elements of the picture set the ObjStatus property (or the OS_CLICK flag in the ObjHotSpot property for MetaDraw) for that element, and then trap the HitObject event.

See also

Click event in the Microsoft Visual Basic Language Reference.


ClientHeight, ClientWidth Properties

Description

These properties return the dimensions of the visible area inside the MetaDraw box, in units specified by the ScaleUnits property or the parent control's ScaleMode, ScaleLeft, ... properties (which by default are in twips).

Usage

w# = [form.]MDraw.ClientWidth [(flags%)]

h# = [form.]MDraw.ClientHeight [(flags%)]

Remarks

The visible area is actually the client area of the MetaDraw's window. If both the border and the scroll bars are disabled on the control, the ClientHeight and ClientWidth properties have the same values as Height and Width. Otherwise, they will be less by the dimensions of the scroll bars and/or the border.

These properties have an optional parameter that determines units of the returned value and whether to incude scrollbars size or not. It can be a combination of the following values:

Value | Description
1 | Add the size of the corresponding scrollbar (if it is visible) to the returned value. It's useful when you want to set the visible size of the MetaDraw picture exactly to the size of the MetaDraw control box.
2 | Always return value in pixels regardless of the parent control's scaling mode.

Data Type

Single

See also

Coordinate properties of MetaDraw, Position and Size of the Control Window ScaleUnits property


ClientToLogicX, ClientToLogicY Properties

Description

The MetaDraw control has several "array" properties (which look like "methods") to convert between the client coordinates (given in pixels) and logical picture coordinates (as determined by the PicLeft, PicTop, PicWidth and PicHeight properties.

Usage

nPicX& = MDraw.ClientToLogicX (nClientX&)

nPicY& = MDraw.ClientToLogicY (nClientY&)

Remarks

MetaDraw uses a subscript of an "array" as an input parameter for the conversion function. However, they look like and work like methods.

Note: The client window coordinates are measured in screen pixels regardless of the units specified by the parent control. You can use the parent control's ScaleMode, ScaleLeft, ... properties for converting other units to pixels.

Example

' Update Label captions with the current mouse position
Sub MetaDraw_MouseMove (Button As Integer, Shift As Integer, _
                        X As Single, Y As Single)
    Dim LogicX As Integer, LogicY As Integer
    LogicX = MetaDraw.ClientToLogicX(X / Screen.TwipsPerPixelX)
    LogicY = MetaDraw.ClientToLogicY(Y / Screen.TwipsPerPixelY)
    Label1.Caption = "X = " & X
    Label2.Caption = "Y = " & Y
    Label3.Caption = "Logical X = " & LogicX
    Label4.Caption = "Logical Y = " & LogicY
End Sub

' Add text object on MouseUp event at the current position
Sub MetaDraw_MouseUp (Button As Integer, Shift As Integer, _
                      X As Single, Y As Single)
    Dim LogicX As Integer, LogicY As Integer
    LogicX = MetaDraw.ClientToLogicX(X / Screen.TwipsPerPixelX)
    LogicY = MetaDraw.ClientToLogicY(Y / Screen.TwipsPerPixelY)
    MetaDraw.AddObject OT_TEXT, LogicX, LogicY, LogicX, LogicY
    MetaDraw.TextHAlign = 1: MetaDraw.TextVAlign = 1
    MetaDraw.Text = "(" & X & "," & Y & ")"
End Sub

Data Type

Long

See also

Coordinate properties of MetaDraw, LogicToClientX, LogicToClientY properties


ClipLeft, ClipTop, ClipWidth, ClipHeight Properties

Description

These properties specify a clipping area - cropping the picture which will be exported (via the Picture, PictureClip, ExportDC properties) in units specified by the ScaleUnits property or the parent control scaling mode (by default is in twips).

Remarks

Only that portion of the picture within the rectangle specified by the ClipLeft, ClipTop, ClipWidth, ClipHeight properties will be exported.

These properties are applied only when the EXOPT_CLIPPING flag is specified in the ExportOptions property. Otherwise they are ignored.

If one of the ClipWidth, ClipHeight properties is set to 0, MetaDraw calculates this property automatically according to the picture aspect ratio. If both of these properties are 0, values of the PicXSize, PicYSize properties are used correspondingly.

These properties are measured in units that determined by the ScaleUnits property of the parent container (similar to the PicXSize, PicYSize properties).

By default the entire picture is exported.

Example

' This example prints only visible area of MDraw
Sub cmdPrint_Click()
    MDraw.ExportOptions = EXOPT_USEZOOM + EXOPT_CLIPPING
    MDraw.ClipLeft = MDraw.PicXOfs
    MDraw.ClipTop = MDraw.PicYOfs
    MDraw.ClipWidth = MDraw.ClienWidth
    MDraw.ClipHeight = MDraw.ClienHeight
    MDraw.Current = OBJ_CONT_MAIN
    MDraw.ExportDC = Printer.hDC
End Sub

See also

Printing with MetaDraw, ExportOptions property, ExportDC property


ColorReduction Method

!!! This feature requires MetaDraw Vectorization License Option !!!

Description

The ColorReduction method reduces the number of color of the given picture (bitmap) to the specified value.

Declaration

Function ColorReduction Ê
Ä (ByVal Picture As Picture, Ê
Ä ByVal nNumColors As Integer) As Picture

Returns

The method returns a new (bitmap) picture with a palette of no more than nNumColors colors.

In case of errors (DLL not found or input is not a-Raster image) the function returns a null picture.

Remarks

Before vectorizing an image it is recommended to reduce the number of colors in the image (at a maximum there should be 256 colors before vectorizing). Reducing the number of colors helps to deal with possible errors introduced into an image as a result of scanning as well as reducing the number of vector objects - (each vector object will have at most one color so that two nearly identical colors next to each other may appear to the eye as a single object but will be treated as two seperate objects when vectorizing).

This function applies only to raster images (BMP, JPG, PNG) before conversion to vector format).

Note that nNumColors should be less than 256.

Example

' Convert picture from a picture box to 16-colors picture
MetaDraw.Picture = MetaDraw.ColorReduction Picture1.Picture, 16

See also

Vectorization Method, NoiseReduction Method


CopyToClipboard Method

Description

Copies MetaDraw's picture, or any set of objects to the clipboard.

Declaration

Function CopyToClipboard Ê
Ä (ByVal ClbMask As Integer, Ê

Ä ByVal PicSrc As Integer) As Integer

Syntax

result% = CopyToClipboard (ClbMsk%, PicSrc%)

Parameters

The CopyToClipboard method uses these arguments:

Argument | Description
ClbMask% | Determines formats of data storing to the clipboard.
PicSrc% | Specifies which picture should be copied to the clipboard.

The ClbMask% parameter also determines whether to clear old clipboard contents or not. Multiple formats can be stored into the clipboard at one time by forming a combination of the following values:

Constant | Value | Description
CLB_METADRAW | 0x01 | Store picture in MetaDraw internal format
CLB_BITMAP | 0x02 | Store as bitmap
CLB_DIB | 0x04 | Store as DIB
CLB_PALETTE | 0x08 | Store MetaDraw's picture palette
CLB_METAFILE | 0x10 | Store as metafile
CLB_ENHMETAFILE | 0x20 | Store as enhanced metafile
CLB_CLEAR | 0x100 | Clear old clipboard contents before storing data

The PicSrc% parameter specifies exactly what is copied to the clipboard:

Constant | Value | Description
PIC_PICTURE | 0 | Copy the entire main picture.
PIC_PICTUREIMAGE | 1 | Copy the picture that is determined by the PictureImage property (temporary image).
PIC_PICTURECLIP | 2 | Copy all selected objects from the current open container.
PIC_PICTURECURRENT | 3 | Copy object(s) specified by the .Current property.

Returns

Bitwise mask of data formats (see CLB_xxxxx constants), specifying what formats have successfully been copied to the clipboard. If no format could be copied to the clipboard, the function returns zero.

Remarks

You should select objects you want to copy to the clipboard, before calling this method with picSrc% set to PIC_PICTURECLIP.

Note: It is not possible to copy a Link object without the objects being linked in MetaDraw internal format.

Example

' The following line copies the main MetaDraw picture
' to the clipboard in MetaDraw internal format
MetaDraw.CopyToClipboard CLB_METADRAW, PIC_PICTURE
' The following line clears old clipboard contents
' and copies objects from the open container to
' the clipboard as Metafile and DIB
MetaDraw.Current = OBJ_CONTAINER
MetaDraw.CopyToClipboard CLB_METAFILE + CLB_DIB + CLB_CLEAR, PIC_PICTURECURRENT

See Also

PasteFromClipboard method, PictureClip property


CreateImageMap Method

Description

This method creates an HTML Client Side ImageMap as a string ImageMap representing HotSpot areas in MetaDraw.

Declaration

Function CreateImageMap ( _ Ê
Ä ByVal MapName As String [, ByVal PicSrc As Long] ) As String

Syntax

Map$ = [form.]MDraw.CreateImageMap ("MapName")

Parameters

This function accepts the following parameters:

Parameter | Description
MapName | Name to be assigned for the MAP section. It should be used in <IMG> tag as usemap="#<MapName>"
PicSrc (optional) | Identifies whether ImageMap is created based on entire image or only on selected objects. It may be one of the following values: PIC_PICTURE - The whole picture (default value) PIC_PICTURECLIP - The selected objects. Note that all coordinates are counted from top-left corner of the bounding rectangle of selected objects.

Returns

The CreateImageMap method returns a String containing a Client Side HTML ImageMap representing the HotSpot areas in MetaDraw which have associated URL's.

Remarks

The CreateImageMap method supports the creation of ClientSide Image Maps only. Server Side maps are not supported. For further information on ImageMap standards refer to

"http://lists.w3.org/Archives/Public/w3c-wai-er-ig/2001Feb/att-0023/01-ImageMapConversion.html"

The returned ImageMap string will be of the following form:

** Spacing and Carriage returns are here for documentation visibility and are not necessarily reflected in the actual output string

<MAP name="<MapName>">
    <AREA href="ObjURL" alt="ToolTipText1" shape="...>
    <AREA href="ObjURL2" alt="ToolTipText2"
          shape="rect" coords="86, 47, 234, 65" >
     <AREA href="http://www.btis.com" alt="Bennet-Tec IS, Inc."
          shape="poly" cords=126, 129, 126, 127, 126, 125">
</MAP>

The exported MAP section will consist of RECT, CIRCLE, and POLY areas according to the following rules:

Object Type | Description
Text, Rectangle, Rounded Rectangle, Solid Picture, Bitmap, Container. | The HotSpot area will be a Rectangle (or Polygon if the object is rotated).
Ellipse | Circle if original ellipse is circular and not rotated or Polygon if non-circular or if rotated.
Polyline, Polygon | The HotSpot area will be a Polygon.
Other (Chord, Pie, Arc, Bezier, Line, Dim Line, Link, …) | Not currently supported and will be ignored.

ImageMap elements will only be taken from objects with a defined (non-empty) ObjURL property setting and OS_WEBURL flag set in the ObjStatus property.

Tooltips may be assigned to each hotspot element using the ObjTags property with tag name "TOOLTIP" (NOTE that tag names are case sensitive – this must be all Caps). These tooltips will be included in the ImageMap and will show up within the web browser when the mouse hovers over the tagged area.

The CreateImageMap method does not create the HTML File, just the ImageMap string. This can then be added to an HTML by the developer's code building the HTML File. Also developers should include <IMG> tag with reference to the corresponding <MAP> section into the HTML file by themselves.

Example

With MetaDraw
    ' Load Some Initial Picture
    MetaDraw.LoadPicture   FileName, Pic_Picture

    ' Add the HotSpot Areas
    .AddObject OT_Rectangle, 100,100, 150, 150
    .ObjURL = "http://www.Bennet-Tec.Com/MetaDraw.htm"
    .ObjStatus = OS_WEBURL Or OS_CURSOR Or OS_HOTSPOT
    .ObjVisible = False
    ' or = True depending on whether the object itself should be shown as part of the picture or only use it's boundaries as an invisible hotspot area.
    .ObjTags("TOOLTIP") = "click on me for information on MetaDraw"

    .AddObject OT_Ellipse, 50,50, 100, 100
    .ObjURL = "http://www.Bennet-Tec.Com/Order.htm"
    .ObjStatus = OS_WEBURL Or OS_CURSOR Or OS_HOTSPOT
    .ObjVisible = False
    .ObjTags("TOOLTIP") = "click on me for a good time"

    ' Save the overall Image (excluding Hidden elements)
    .ExportOptions = .ExportOptions OR EXOPT_VISIBLE
    .SavePicture "ImageMap.jpg", PIC_PICTURE, PICTYPE_JPGFILE

    ' Create a simple HTML file with IamgeMap section
    FlNum = FreeFile()
    Open "ImageMap.htm" For Output As FlNum
    Print #FlNum, "<HTML> <BODY>" & vbCrLf
    Print #FlNum, .CreateImageMap("ImageMap", PIC_PICTURE)
    Print #FlNum, vbCrLf & _
        "<IMG src=""ImageMap.JPG"" ismap usemap=""#ImageMap"">" & _
        vbCrLf & vbCrLf & "</BODY></HTML>" & vbCrLf
    Close #FlNum
End With

See Also

ReadImageMap method


CreateLink Method

Description

Creates a new link between the specified objects.

Declaration

Sub CreateLink Ê
Ä (ByVal hndStr As Long, ByVal hndEnd& As Long Ê
Ä ByVal lnkType% As Integer)

Syntax

MetaDraw.CreateLink hndStr&, hndEnd&, lnkType%

Parameters

The CreateLink method uses these arguments:

Argument | Description
hndStr&, hndEnd& | Start and end objects for link
lnkType% | Determines link style:
 | Constant | Value | Description
 | LINK_STRAIGHT | 0 | Create a straight link;
 | LINK_SEGMENTED | 1 | Create a multi-segmented link.

Returns

Upon return this method sets the .Current property to either:

  • OBJ_NULL if no link was created.
  • The handle of a new link.
  • OBJ_SELECTED if multiple links have been created.

Remarks

The hndStr&, hndEnd& parameters determine handles of objects that must be linked. One of these parameters or both can be OBJ_SELECTED.

If OBJ_SELECTED is set as one of parameters, this method will create several links at a time. Setting the hndEnd& parameter to the reserved handle OBJ_SELECTED creates multiple links, starting from the object whose handle is specified by the hndStr& parameter, and ending at each of the selected objects. When the hndStr& parameter is OBJ_SELECTED, links will start at each of the selected objects and end at the object whose handle is specified by the hndEnd& parameter.

If both of these parameters are OBJ_SELECTED multiple links will be created and first selected object will be as start object for links.

When LINK_SEGMENTED is specified as link type, MetaDraw will create a default segmented link (link that contains three segments). The SetParams method may then be used to change the position of link segments or to add new segments.

All parameters of the new link are initially set to default values (as previously specified when .Current is set to OBJ_DEFAULT). All new links are automatically connected to the corresponding objects. Use the SetLinkPoint method to change link's connection points.

After calling the CreateLink method, any previously selected objects become unselected, and the new link itself is selected. The Current property will point to the new link, or if multiple link objects are created .Current will be set to OBJ_SELECTED.

Remarks

' This code creates two objects and make a link between them
MDraw.AddObject OT_RECTANGLE, 100, 100, 300, 300
hndObj& = MDraw.Current
MDraw.AddObject OT_ELLIPSE, 400, 500, 600, 800
MDraw.CreateLink hndObj&, MDraw.Current, 0

See Also

Link Attributes, SetLinkPoint method


Current Property

Description

This property determines the object, or group of objects, that are being used, referenced or affected by the specified action (change objects attributes, move, group objects, etc.).

Usage

[form.]MDraw.Current [= object_handle&]

Remarks

All object-related properties apply to the Current object (which may be one graphic element or a reference to a group of elements). You should assign an object handle or one of the predefined scope constants (see table below) to this property before performing any manipulations with the object(s).

After AddObject method or function call, the Current property is automatically set to the handle of the graphic element just added.

After RemoveObject method or function call, the Current property is automatically reset to OBJ_NULL, if an object handle was specified for deleting. * The value of the Current property will not be changed if a reserved handle had been specified as a function or method parameter or in the Current property.

MetaDraw automatically sets the Current property to a proper value before firing an event.

The following reserved object handles have special meaning:

Constant | Value | Description
OBJ_NULL | 0 | Refer no objects - can be returned after an action has failed
OBJ_CONTAINER | 1 | The current open container
OBJ_SELECTED | 2 | All selected objects
OBJ_SEL_ATTR | 3 | All selected objects and global MetaDraw object's attributes for getting/setting attribute operations
OBJ_DEFAULT | 4 | Used to set default attributes. Attributes set while .Current = OBJ_DEFAULT will apply to any objects created afterwards.
OBJ_CURR_ATTR | 4 | ( same as OBJ_DEFAULT - for backward compatibility)
OBJ_CONT_MAIN | 5 | Specifies the Main Container

OBJ_SEL_ATTR and OBJ_DEFAULT are valid only for getting/setting attributes of an object (like LineColor, Text, BackStyle, DrawMode). OBJ_DEFAULT value can be used to change default object attributes (text styles, font styles, colors, line width, link attributes, shadows, …) prior to creation of graphic objects.

When the Current property is OBJ_SEL_ATTR, an action of setting attributes will set the corresponding attribute for the global MetaDraw object (default attributes) as well as for all selected objects.

When the Current property is set to OBJ_SEL_ATTR and an action of reading an attribute property has failed (for example, the user tries to read the FillColor property for selected objects and the selected objects have different colors) MetaDraw returns the default value for this attribute.

Data Type

Long (The Object handle)

See also

Changing object's attributes, Object Handles


DblClick Event

Description

This standard event occurs when the user double-clicks a mouse button over a MetaDraw control.

Syntax

Private Sub MetaDRAW_DblClick ([Index As Integer])

See also

DblClick event in the Microsoft Visual Basic Language Reference.


Drag Method

Description

This standard method begins, ends, or cancels dragging the MetaDraw control.

Syntax

MDraw.Drag [action%]

Parameters

The action% parameter can have one of the following three values:

Value | Action
0 | Cancel drag operation.
1 (default) | Start dragging the MetaDraw.
2 | Stop dragging (drop the control).

Remarks

Note: MetaDraw also supports OLE Drag-&-Drop technique. For more information see OLEDragDrop properties.

See also

Drag method in the Microsoft Visual Basic Language Reference.


DragDrop, DragOver Events

Description

These standard events occur when another control is dragged over the MetaDraw control (the DragOver event) and when it is dropped on the MetaDraw control (the DragDrop event).

Syntax

Sub MDraw_DragDrop ([Index As Integer,] Source As Control, Ê
Ä X As Single, Y As Single)

Sub MDraw_DragOver ([Index As Integer,] Source As Control, Ê
Ä X As Single, Y As Single, State As Integer)

See also

DragDrop, DragOver events in the Microsoft Visual Basic Language Reference.


DragIcon Property

Description

This standard property determines the icon to be displayed as the mouse cursor when the MetaDraw control is being dragged.

Usage

[form.]MDraw.DragIcon [= LoadPicture(...)]

Data Type

Picture (Icon)

See also

DragIcon property in the Microsoft Visual Basic Language Reference, MouseCursor property.


DragMode Property

Description

This standard property determines manual or automatic dragging mode for a drag-and-drop operation.

Usage

[form.]MDraw.DragMode [= setting%]

Settings

The DragMode property settings are:

Setting | Value | Description
Manual (default) | 0 | Requires using the Drag method to initiate dragging on the source control.
Automatic | 1 | Pressing of the left mouse button over the source control automatically initiates dragging.

Data Type

Integer (Enumerated)

See also

DragMode property in the Microsoft Visual Basic Language Reference.


DrawMode Property

Description

The DrawMode property specifies the way in which object's attributes (pen, brush or characters) are combined with the colors already on the display surface. The DrawMode property can accept one of the 16 standard modes of the Windows SetROP2() function.

Usage

[form.]MDraw.DrawMode [= setting%]

Settings

The DrawMode property settings are:

Constant | Value | Formula | Calculate
R2_BLACK | 1 | 0 | Blackness
R2_NOTMERGEPEN | 2 | ~(PaD) | Not Merge Pen
R2_MASKNOTPEN | 3 | (~P)oD | Mask Not Pen
R2_NOTCOPYPEN | 4 | ~P | Not Copy Pen
R2_MASKPENNOT | 5 | Pa(~D) | Mask Pen Not
R2_NOT | 6 | ~D | Invert
R2_XORPEN | 7 | PxD | Xor Pen
R2_NOTMASKPEN | 8 | ~(PaD) | Not Mask Pen
R2_MASKPEN | 9 | PaD | Mask Pen
R2_NOTXORPEN | 10 | ~(PxD) | Not Xor Pen
R2_NOP | 11 | D | Nop
R2_MERGENOTPEN | 12 | (~P)oD | Merge Not Pen
R2_COPYPEN | 13 | P | Copy Pen
R2_MERGEPENNOT | 14 | Po(~D) | Merge Pen Not
R2_MERGEPEN | 15 | PoD | Merge Pen
R2_WHITE | 16 | 1 | Whiteness

Remarks

The Calculate column of the above list contains the expression of the bitwise logical operation to be performed on the pen and the pixels of the destination DC. 'D' means the destination DC, 'P' means the pen, 'a, x, o, ~' - logical operators 'and, xor, or, not' accordingly. For example, '(~P)oD' means

Result = (not Pen) or Dest
Note: Objects are displayed according to their stacking order, so all operations are performed from the bottom-most object to the topmost one.

Data Type

Integer (Enumerated)

See also

Object stacking order, Changing object's attributes, Windows API function SetROP2().


DropFile Event

Description

Occurs when the user drops one or several files from Windows Explorer or File Manager into the MetaDraw control.

Syntax

Sub MDraw_DropFile ([Index As Integer,] Ê
Ä ByVal X As Long, ByVal Y As Long, Ê
Ä ByVal FName As String, FIndex As Integer)

Remarks

Parameters of the DropFile event are:

Parameter | Description
X, Y | The client coordinates (in pixels) of the point where the files were dropped. Use (X, Y) to find out which exact location on the picture the files have hit.
FName | The name of the dropped file. If several files are dropped, the DropFile event is fired either for each file in the list or only for the first one, depending upon the DropMode property setting.
FIndex | The index of the currently processed file (FName) in the list of dropped files. The first file in the list has index 0. When multiple files are processed, FIndex is incremented on every call to the DropFile event. Usually, this parameter is not needed. But, you can decrement it to process the given file again or set it to -1 if no more files should be processed.

See also

Dropping Files from Windows Explorer, OLE Drag-&-Drop, DropMode property


DropMode Property

Description

This property determines how the MetaDraw control should handle filenames dropped from the Windows Explorer.

Usage

[form.]MDraw.DropMode [= setting%]

Settings

The DropMode property settings are:

Constant | Value | Description
FDROP_NONE | 0 | Disable the processing of dropped files.
FDROP_FIRST | 1 | Process (generate an event for) only the first file in the list.
FDROP_ALL | 2 | Process (generate an event for) each file in the list.

Remarks

Code should be written in the MetaDraw_DropFile(...) event procedure to handle dropped files. For example, you can load the picture and assign it to the control's picture property.

Sub MetaDraw_DropFile (..., FName As String, ...)
    MDraw.Picture = LoadPicture(FName)
End Sub

Data Type

Integer (Enumerated)

See also

Dropping Files from the Windows Explorer, DropFile event


DXFScaleFactor Property

Description

After reading the DXF file MetaDraw stores the conversion ratio between coordinate system used in teh DXF file and MetaDraw logical units into this property.

Usage

[form.]MDraw.DXFScaleFactor = setting#

Remarks

This property allows to determine what the logical coordinate system is that MetaDraw used after it performed the DXF import.

See Also

DXF format importing/exporting


EditFlags Property

Description

This property determines which mouse actions are available to the end-user when the EditMode property is set to ED_EDIT (ED_SELECT).

Usage

[form.]MDraw.EditFlags [= edit_flg%]

Settings

The EditFlags property is a collection of 1-bit flags. It may be set by OR'g the desired Flags from the following list:

Constant | Value | Description
EFLG_SELECT | 1 | If this bit is set, a Left mouse button click selects an object.
EFLG_SELSHIFT | 2 | If this bit is set, a Left mouse button click while holding the SHIFT key toggles the selection status of underlying object. This allows the end-user to select multiple objects.
EFLG_SELGROUP | 4 | If this bit is set, then all objects located inside the selection rectangle will be marked as "selected."
EFLG_DRAWSCEL | 8 | Determines how an object will be drawn while it is being dragged. If this bit is set, only the outline of the moving object will be drawn. Otherwise the whole object will be drawn while mouse is dragging.
EFLG_MOVE | 16 | If this bit is set, Object(s) can be moved by the end-user dragging on them with the left mouse button.
EFLG_RESIZE | 32 | If this bit is set, an end-user can resize an object by dragging one of the border markers using the mouse.
EFLG_OPEN | 64 | If this bit is set, a double-click of the left mouse button opens an underlying object (container, text, or Poly Object.) for editing / manipulation.
EFLG_KEEPRATIO | 128 | If this bit is set, MetaDraw will try to keep the aspect ratio of an objects resized by user dragging corner marker.
EFLG_KEEPOBJECT | 256 | When this bit is set, the object's aspect ratio will only be kept for complex objects (container, pictures and bitmaps). Otherwise, MetaDraw keeps the ratio for all objects.
EFLG_EDITSHAPE | 512 | If this bit is set selecting Arc, Sector, Chord or RoundRectangle will display yellow markers for end-user to edit shapes
EFLG_DONTSCROLL | 1024 | When this bit is set the picture is not scrolled when moving an object. Otherwise dragging an image element beyond the client window will cause MetaDraw to scroll
EFLG_POLYFREEHAND | 2048 | Determines polygons and polylines drawing method. When the bit is set each click of mouse draws a straight segment, and a double-click completes the shape. When NOT set lifting the mouse completes the drawing of the shape - use <Shift> key to draw line sections of polygon.

Remarks

By default all flags are set in this property.

Flags EFLG_SELSHIFT and EFLG_SELGROUP should be set only with the EFLG_SELECT flag. The EFLG_KEEPOBJECT flag is also ignored when EFLG_KEEPRATIO is not set.

Data Type

Integer

Example

' Turn on auto scrolling in response to user dragging of objects,
' and turn on Freehand mode
MetaDraw.EditFlags = MetaDraw.EditFlags _
And Not (EFLG_DONTSCROLL Or EFLG_POLYFREEHAND)

See also

Editing objects, EditMode property.


EditMode Property

Description

This property determines the effect of mouse actions in the MetaDraw control window.

Usage

[form.]MDraw.EditMode [= setting%]

Settings

The EditMode property settings are:

Constant | Value | Description
ED_VIEW | 0 | No mouse edit action
ED_LINE | 1 | Add line mode
ED_RECT | 2 | Add rectangle mode
ED_ROUND | 3 | Add rounded rectangle mode
ED_ELLIPSE | 4 | Add ellipse mode
ED_ARC | 5 | Add arc mode
ED_PIE | 6 | Add pie mode
ED_CHORD | 7 | Add chord mode
ED_POLYLINE | 8 | Add polyline mode
ED_POLYGON | 9 | Add polygon mode
ED_TEXT | 10 | Add text mode
ED_EDIT | 11 | Edit object(s) mode
ED_SELECT | 11 | Select object(s) mode
ED_IMAGE | 12 | Add image mode
ED_ROTATE | 13 | Mouse Drags and Rotates objects
ED_BEZIER | 14 | Add Bezier curve mode
ED_DIMLINE | 22 | Add dimension line mode
ED_LINKLINE | 23 | Add/Draw Link Lines between other elements
ED_ZOOM | 24 | Zoom / UnZoom by clicking

Remarks

The mouse cursor within the MetaDraw control box has a specific appearance for each edit mode. In the view mode (ED_VIEW value), the mouse is the standard arrow cursor or that cursor specified by the MousePointer property.

In Selection/Edit mode (ED_SELECT or ED_EDIT) the end-user can select, move or resize objects using the mouse. Any or all of the editing actions can be disabled by appropriately setting the EditFlags property.

In View mode (ED_VIEW), no edit action is performed, but events dependent upon the Hotspots, EventMask properties will be triggered.

In Rotate mode (ED_ROTATE) users may rotate objects by dragging corner markers. This EditMode is available only for MetaDraw.

In Arc, Chord, and Pie edit modes ( ED_ARC, ED_CHORD, ED_PIE ) the user will be able to draw ¼ circle objects ( 90 degrees). The object can then be further edited in ED_EDIT mode after double clicking.

In Link Edit Mode (ED_LINK) users can click on one object and then another to draw a link between the objects. The link may then be edited in ED_EDIT mode after double clicking on the link, or in ED_LINK mode if the object is programmatically opened using OBJOPENED = True

In Zoom edit mode (ED_ZOOM) user can zoom in on some portion of the image by drawing the bounding rectangle of the zoom region. Simple clicking will also zoom the image by a fixed percentage. Holding the Control key while clicking in this mode will unzoom ( shrink) the image.

Data Type

Integer (Enumerated)

See also

Objects selecting, Objects editing, Add object using mouse, EditFlags property


EmbeddedControls Method

Description

MetaDraw supports the embedding of controls within the picture. In general any control that supports the Move method can be inserted into a MetaDraw picture. (Bennet-Tec can not guarentee support for other 3rd party controls)

Controls may be embedded as ordinary children (as with a frame) or as actual parts of the diagram / picture. Such embedded controls may be Scrolled and or zoomed with the picture.

To embed a control in MetaDraw, add the control at design time within MetaDraw as you would add a control to a frame. The EmbeddedControls: method may be called to specify how embedded controls behave.

Usage

Function EmbeddedControls ([Value As Integer]) As Long

Settings

The EmbeddedControls property settings are:

Setting | Value | Description
EMB_NONE | 0 | (default) Do not scroll or resize embedded controls, treat them as ordinary child controls within a frame.
EMB_SCROLL | 1 | Scroll controls with MetaDraw picture
EMB_SCROLLSHIFT | 2 | Scroll controls and shift top left corner as may be needed when zooming.
EMB_SCROLLSIZE | 3 | Scroll and Resize controls with MetaDraw picture

Data Type

Long

Remarks

Embedded controls may be accessed through the Container.Controls collection

Support for Embedded controls is subject to certain limitations:

  • Embedded controls are not supported under FoxPro programming environment and may not function under certain other environment which do not provide support for ISimpleFrame interface.
  • End-Users may interact with embedded controls in normal manner ( clicking on button, typing in text) only when MetaDraw's EditMode property is set to ED_VIEW.
  • The Align property of an Embedded Control will not for controls contained in MetaDraw.
  • Embedded Controls must be initially placed in MetaDraw at design time.
  • MetaDraw "zooms" embedded controls by resetting the Height and Width properties of all embedded controls. The embedded controls will thus not be truly zoomed – The effect will depend on the type of control ( for instance a listbox may now show more items at the same font when the image is enlarged, but a button control will certainly look like a larger button)
  • Embedded controls are not currently included within the image when printing or saving to file. This support is expected to be added at a later date for users with Subscription License support
  • Embedded controls are not recognized as image elements by Metadraw and can not currently dragged or resized by end-user, or be connected with diagram links. This support is anticipated for later release to be available to users purchasing Subscription License option.

Example

' Get the number of controls embedded in MetaDraw
count = MetaDraw.EmbeddedControls ()
' Scroll and Resize embedded controls with MetaDraw picture
count = MetaDraw.EmbeddedControls (  EMB_SCROLLSIZE )

See Also

How to work with Embedded Controls


Enabled Property

Description

This standard property determines if the control can respond to user-generated events.

Usage

[form.]MDraw.Enabled [= {True|False}]

Settings

The Enabled property settings are:

Setting | Description
True (default) | Allows the MetaDraw control to respond to events.
False | Prevents the MetaDraw control from responding to events.

Data Type

Integer (Boolean)

See Also

Enabled property in the Microsoft Visual Basic Language Reference.


EventMask Property

Description

This property determines which events can be triggered.

Usage

[form.]MDraw.EventMask [= event_mask%]

Settings

The EventMask property can be a combination of the following values:

Constant | Value | Description
EMSK_HITOBJECT | 1 | Enable HitObject Event.
EMSK_ONHOTSPOT | 2 | Enable OnHotSpot Event.
EMSK_SELECT | 16 | Invoke Change event when object(s) selection is changed.
EMSK_ADD | 32 | Invoke Change event when new object is added.
EMSK_MOVE | 64 | Invoke Change event when an object is moved.
EMSK_RESIZE | 128 | Invoke Change event when a marker is moved.
EMSK_OPEN | 256 | Invoke Change event when an object or a container is opened.
EMSK_CHANGE | 512 | Invoke Change event when an object's attribute is moved.
EMSK_DELETE | 1024 | Invoke Change event when an object is deleted.

Remarks

The Change event can be disabled by clearing all following bits: EMSK_SELECT, EMSK_ADD, EMSK_MOVE, EMSK_RESIZE, EMSK_OPEN, EMSK_CHANGE, EMSK_DELETE.

By default, all events are enabled. You can disable any unneeded events for better performance.

Data Type

Integer (The Bitwise mask)

See also

Change event, HitObject event, OnHotSpot event.


Export Event

Description

Occurs when objects are exported to another device context (after setting the ExportDC property).

Syntax

Private Sub MDraw_Export ([Index As Integer,] Ê
Ä ByVal ObjNum As Long, State As Integer)

Parameters

Parameter | Description
ObjNum& This parameter depends on the second parameter (State)
  • If State parameter is EXP_PROCESS, this parameter specifies the number of the currently exported object (number for first object is 1).
  • If State parameter is EXP_START or EXP_FINISH this parameter specifies the total number of exported objects
Constant | Value | Description
EXP_FINISH | 0 | Finish the exporting of objects.
EXP_START | 1 | Starting the exporting of objects.
EXP_PROCESS | 2 | Now Exporting for current object.
EXP_SKIP | 3 | Skip the current object.
State% | Determines the phase of exporting. This parameter can have the following values:

Remarks

The event will be called repeatedly, once at the start of exporting, once for each object being exported, and once to indicate completion.

Before triggering this event, MetaDraw resets the Current property to the handle of object currently being exported.

This event is triggered before exporting an object, so it is possible to skip this object (do not export it) by the State parameter to EXP_SKIP (3) before exit. The user can interrupt exporting (printing) all objects by assigning the State parameter to EXP_FINISH (0).

See also

Printing with MetaDraw, ExportDC property, ExportLeft, ExportTop properties, ExportWidth, ExportHeight properties.


ExportDC Property

Description

Setting the ExportDC property initiates Printing

Usage

[form.]MDraw.ExportDC = hDC&

also:

[form.]MDraw.ExportDC = -1 ' or = -2

Values

Setting ExportDC to a specified Device Context causes MetaDraw to printing to that device context (for example to send the image to the printer).

A setting of -1 (EXPORT_DEFAULTPRINTER ) instructs MetaDraw to prints to the default printer as one page.

A setting of -2 (EXPORT_CHOSENPRINTER ) instructs MetaDraw to present a Printer Selection dialog, allowing the end-user to chose the printer, the page settings and the number of copies. When the "OK" button is pressed, MetaDraw prints the specified number of pages on the chosen printer.

Remarks

After the assignment of a valid device context, the MetaDraw control starts drawing objects on specified device context (hDC%). Objects which should be exported are specified in the Current property.

The MetaDraw control always fires the Export event with the State parameter set to EXP_START (before exporting), EXP_PROCESS for each exported object and EXP_FINISH after exporting the last object. You can interrupt exporting at any time by setting the State parameter to EXP_FINISH in the Export event.

The ExportLeft, ExportTop and ExportWidth, ExportHeight properties determine the size and position of the exporting picture if ExportOptions includes the EXOPT_EXPORTRECT flag

The ClipLeft, ClipTop, ClipWidth, ClipHeight properties specify the clipping area of the exported picture if ExportOptions includes the EXOPT_CLIPPING flag

Typically, you are assigning either -1, -2, or Printer.hDC to this property, which actually prints the objects in the MetaDraw control box.

When setting ExportDC to either -1 or -2 , MetaDraw initializes the printer, prints, and then ends the print job directly. There is no need to initialize the printer or to call EndDOC statements or any other code. The limitation is that in this case MetaDraw can only print a single page, and it is not possible to add additional information to the page before it is ejected.

Additional printing options may be specified with the ExportOptions property.

Example

' Example 1
' Print the entire picture to printer chosen by end user
    MDraw.Current = OBJ_CONT_MAIN
    MDraw.ExportDC = EXPORT_CHOSENPRINTER    ' = -2
' Example 2
' This code prints only selected objects to the specified printer
Sub cmdPrint_Click()
    Printer.ScaleMode = 3   ' Pixels
    Printer.Print ""   ' initialize - not req'd if ExportDC = -1 or -2
    MDraw.ExportOptions = EXOPT_PIXELS Or EXOPT_EXPORTRECT
    ' Set the picture placement and sizes
    MDraw.ExportLeft = 720 / Printer.TwipsPerPixelX
    MDraw.ExportTop = Printer.CurrentY + 720 / Printer.TwipsPerPixelY
    MDraw.ExportWidth = 2880 / Printer.TwipsPerPixelX  ' two inches
    MDraw.ExportHeight = 0  ' calculate automatically
    Screen.MousePointer = 11
    ' Print the selected objects in the picture
    MDraw.Current = OBJ_SELECTED  ' Only selected objects
    MDraw.ExportDC = Printer.hDC
    Printer.NewPage    ' not needed if ExportDC = -1 or -2
    Screen.MousePointer = 0
    Printer.EndDoc    ' not needed if ExportDC = -1 or -2
End Sub

Data Type

Integer (The Device Context)

See also

Printing with MetaDraw,
ClipTop, ClipLeft, ClipHeight, ClipWidth properties.
Export event, ExportLeft, ExportTop properties,
ExportWidth, ExportHeight properties, ExportOptions property


ExportLeft, ExportTop, ExportHeight, ExportWidth Properties

Description

Determine the placement (margin offsets) and the width and height of the exported (printed) picture.

The ExportHeight, ExportWidth properties are also used to determine the dimensions of a bitmap which will be returned by Picture, PictureImage and PictureClip properties when the PictureType property is set to PICTYPE_BITMAP.

Usage

[form.]MDraw.ExportLeft [= ofsX&]

[form.]MDraw.ExportTop [= ofsY&]

[form.]MDraw.ExportWidth [= width&]

[form.]MDraw.ExportHeight [= height&]

Remarks

If one of the ExportHeight, ExportWidth properties is set to zero before exporting, MetaDraw will automatically calculate the appropriate value for that property in order to preserve the picture aspect ratio.

These properties may be specified in either twips or pixels, as determined by the EXOPT_PIXELS flag of the ExportOptions property.

These properties are applied only when the ExportOptions property contains the EXOPT_EXPORTRECT flag. Otherwise the physical picture size is used to calculate the destination rectangle.

Data Type

Long

See also

Printing with MetaDraw, ExportDC property


ExportOptions Property

Description

This property specifies how to export objects when printing (ExportDC property), or when reading the Picture and PictureClip properties.

Usage

[form.]MDraw.ExportOptions [= OptionBitFlag%]

Remarks

This is a bitwise value based on a combination of the following bits:

Constant | Value | Description
EXOPT_DEFAULT | 0x000 | Use defaults.
EXOPT_CLIPPING | 0x001 | Crop the exported image. Only that portion of the picture within the rectangle specified by the ClipLeft, ClipTop, ClipWidth, ClipHeight properties will be exported. By default, the entire picture is exported.
EXOPT_EXPORTRECT | 0x002 | Specify coordinates of destination rectangle within export DC. The ExportLeft, ExportTop, ExportWidth, ExportHeight properties determine the destination rectangle. By default, offset is always (0,0) and size is calculated according to physical picture sizes.
EXOPT_USEZOOM | 0x008 | Determines whether the clipping region is taken from the visible picture (in it's zoomed state) or from the original picture.
EXOPT_TRANSPARENT | 0x010 | Do NOT include picture background when exporting objects.
EXOPT_PIXELS | 0x020 | The ExportLeft, ExportTop, ExportWidth, ExportHeight are specified in device pixels. By default, they are in twips.
EXOPT_BITMAP | 0x080 | Draw objects on a temporary bitmap and then draw it on the specified DC. Setting this flag may be useful when the printer driver does not support some kind of raster operations.
EXOPT_VISIBLE | 0x100 | Include only objects whose Visible flag is set. If this flag is NOT set MetaDraw exports ALL objects regardless of visibility
EXOPT_BACKGROUND | 0x200 | The backgroud determined by the BackPicture and GradientStyle properties is included as part of any exported pictures (using ExportDC, SavePicture or SaveToClipboard functions). (This setting is Ignored if EXOPT_TRANSPARENT is Set.)

Default Value

0

Data Type

Integer (Enumerated)

See also

PrintSize properties: ExportLeft, ExportTop, ExportWidth, ExportHeight
Clipping rectangle properties: ClipLeft, ClipTop, ClipWidth, ClipHeight
ExportDC property


FillColor Property

Description

Determines the color used to fill in objects.

Usage

[form.]MDraw.FillColor [= color_expression&]

Remarks

The FillColor property determines a color for solid fill style or for hatch lines in hatched styles.

This color is also used for the background of the FillPattern picture (metafiles or icon) when it is converted to a brush (bitmap).

Data Type

Long (Color)

See also

Changing object's attributes, BackStyle property, BackColor property


FillPattern Property

Description

Specifies the picture (bitmap) to be used as a fill pattern for an object.

Usage

[form.]MDraw.FillPattern [= LoadPicture(...)]

Remarks

The fill pattern may be set by directly setting the property, or by calling the LoadPicture method with a second parameter of PIC_FILLPATTERN.

If the assigned picture is not a Bitmap, it will be converted to a proper bitmap brush, and the value specified in the FillColor property will be used to fill the background of this picture.

Under Windows NT, the entire picture can be used as a brush pattern.

MetaDraw is also able to stretch a givenpicture to a 8x8 brush pattern (instead of using its top-left corner), if the PICOPT_STRETCHBRUSH flag is set in the PictureOptions property.

After the FillPattern property is assigned successfully, the FillStyle property is set to FS_PATTERN and the FillColor property is ignored.

The typical bitmap for FillPattern should look like a piece of a large regular picture (e.g. a brick in the wall ' [image] ').

Note: If FillStyle is not FS_PATTERN (e.g. was set to FS_SOLID), then FillPattern returns NULL picture.

Data Type

Long (The Picture handle).

Example

' Create a Rectangle with a fill pattern
MetaDraw.AddObject OT_RECTANGLE, 100, 100, 200, 200
MetaDraw.LoadPicture "c:\SomeImageFile", PIC_FILLPATTERN
' FillStyle is automatically set by setting the fill Patt

See also

Changing object's attributes, FillStyle property, PictureOptions property


FillStyle Property

Description

Determines the method used to fill object.

Usage

[form.]MDraw.FillStyle [= setting%]

Settings

The FillStyle property settings are:

Constant | Value | View
FS_SOLID | 0 | solid
FS_TRANSPARENT | 1 | transparent
FS_HORIZONTAL | 2 | =====
FS_VERTICAL | 3 | | | | | |
FS_FDIAGONAL | 4 | \ \ \ \ \
FS_BDIAGONAL | 5 | / / / / /
FS_CROSS | 6 | +++++
FS_DIAGCROSS | 7 | xxxxx
FS_PATTERN | 8 | use bitmap pattern
FS_GRADIENT | 9 | Gradient Fill

The following additional FillStyle property settings may be combined ( Logical OR) with the above :

Constant Value Description
FS_FILLED 256 Fill open curve.

When applied to an Arc, a Bezier or a Polyline object, the non-closed figure will be filled. When applied to a Text ( Standard or Bound) text object, a frame will be drawn around the text and the background will be filled.

This flag can also be used to draw a frame around text objects (Standard or Bounded) and fill the background.

Remarks

The Gradient FillStyle applies a horizontal color gradient to the object(s) specified by .Current property. Objects can have only horizontal gradients. For text objects the gradient changes from TextColor to BackColor, For all other objects, the gradient changes from FillColor to BackColor.

When FillStyle is FS_TRANSPARENT (1), the FillColor property is ignored.

TheFillStyle property can't be set to FS_PATTERN (8), because a bitmap pattern must be specified. The property is set to FS_PATTERN automatically when the FillPattern property changes.

When the LinkFlags property for a link is set to LF_FILLED the FillStyle property determines the fill style of the link terminators.

Example:

' Create a Rectangle with a fill pattern
MetaDraw.AddObject OT_RECTANGLE, 100, 100, 200, 200
MetaDraw.LoadPicture "c:\SomeImageFile", PIC_FILLPATTERN
' FillStyle is automatically set by setting the fill Pattern
' Create an Arc with a Diagonal Fill
MetaDraw.FillStyle = FS_DIAGCROSS Or FS_FILLED
' Create a Rectangle and a Text object with Gradient Fill
With MDrawPro1
    .AddObject OT_RECTANGLE, 10, 10, 600, 100
    .FillColor = vbRed
    .BackColor = vbGreen
    .FillStyle = FS_GRADIENT
    .AddObject OT_TEXT, 10, 110, 10, 110
    .FontSize = 25
    .Text = "G R A D I E N T"
    .TextColor = vbBlue
    .BackColor = vbRed
    .FillStyle = FS_GRADIENT
End With

Data Type

Integer (Enumerated)

See also

Changing object's attributes, BackStyle property, BackColor property, FillColor property, FillPattern property


FindObjectTags Method

Description

This method finds objects that have the specified tags, and characteristics.

Declaration

Function FindObjectTags (ByVal TagName As String, ByVal TagVal As Variant, Ê
Ä ByVal Options As Integer) As Long

Syntax

result& = MetaDraw.FindObjectTags (Name$, varValue, Options%)

Parameters

The FindObjectTags uses these arguments:

Argument | Description
TagName$ | Name of the tag to find, or "*" string
TagValue | Tag value to find
Options% | Combination of searching flags.

The Options% parameters can be a combination (OR) of the following BitFlag values:

Constant | Value | Description
OS_CURSOR | &H0001 | Find only objects which have the "Cursor" status flag.
OS_HOTSPOT | &H0002 | Find only objects which have the "HotSpot" status flag.
OS_CLICK | &H0004 | Find only objects which have the "Click" status flag.
OS_WEBURL | &H0008 | Find only objects which have the "WebURL" status flag.
OS_SELECTED | &H0010 | Search only among selected objects.
OS_VISIBLE | &H0020 | Search only among visible objects.
FND_FIRST | &H0000 | Start searching from the first object in container.
FND_NEXT | &H0100 | Find next object meeting search criteria. The Current property determines an object from which the search begins.
FND_CURRENT | &H0200 | The function attempts to start searching at the object whose handle specified in the Current property. The Current property may contain a reserved handle:
 |  | Constant | Meaning
 |  | OBJ_SELECTED | looking in all selected objects.
 |  | OBJ_CONTAINER | Start from the first object in the open container.
 |  | OBJ_CONT_MAIN | Start from main container (used together with FND_RECURSE flag to search for all picture's objects).
FND_RECURSE | &H0400 | Use recursive search (looking in containers also).
FND_INVERT | &H0800 | Invert the condition.
FND_EXACT | &H1000 | Compare full strings.
FND_MATCHCASE | &H2000 | Use case-sensitive search for strings.
FND_SELECT | &H4000 | Select all found objects.
FND_DESELECT | &H4010 | Deselect all found objects.

Returns

The number of objects found by the search.
Zero, if there are no objects matching the specified criteria: TagName$ and TagValue.

Upon return the Current property is set by MetaDraw to either:

  • OBJ_NULL if no object is found at the specified location.
  • The handle of an object matching the search criteria.
  • OBJ_SELECTED if multiple objects have been found and selected (when the FND_SELECT, FND_DESELECT or FND_INVERT flag was specified in the Options% parameter).

Remarks

The function searches for objects (within the specified container) which have a tag specified by the TagName$ parameter and where the value for the named tag matches the TagValue parameter. Specifying a TagName$ parameter of "*" instructs MetaDraw to ignore tag names and use only the TagValue value as a search criteria. Specifying an empty string as TagValue parameter instructs MetaDraw to ignore tags completely – this may be useful in searching for objects based on their status flags.

Normally the function finds first object whose tag matches the specified values (FND_FIRST value is specified in the Options% parameter). To find the next matching object, include FND_NEXT in the Options% flag parameter. In this case, the Current property must contain the valid object handle (e.g. handle of previously found object).

If the FND_INVERT flag is specified in the Options% parameter, the searching condition will be inverted. That is the function searches for objects whose tags don't match the TagValue parameter.

The function should be called only once when specifying FND_SELECT or FND_DESELECT flags in the Options% parameter. In that case, all matching objects will be selected (or deselected) and the method returns the number of matching objects.

Example

' Example 1:
' The following sample finds all objects, which have a tag
' named "URL" and set to "http://www.bennet-tec.com" and
' changes the HotSpot flag for them.
Dim Opt As Integer
Opt = FND_FIRST
While MDraw.FindObjectTags("URL", "http://www.bennet-tec.com", Opt) > 0
    ' The Current property contains handle of the last found object
    MDraw.ObjHotSpot = 15
    MDraw.ObjURL = MDraw.ObjTags("URL")
    Opt = FND_NEXT    ' Find next object
Wend
' Example 2:
' Find the first object whose OS_WEBURL flag is set
MDraw.FindObjectTags ("*", "", FND_FIRST + OS_WEBURL)

See Also

How to search for objects, ObjTag, ObjTags properties


FontBold, FontItalic, FontStrikethru, FontUnderline Properties

Description

Determines the font style for a text object in the following formats: FontBold, FontItalic, FontStrikethru, FontUnderline.

Usage

[form.]MDraw.FontBold [= {True|False}]

[form.]MDraw.FontItalic [= {True|False}]

[form.]MDraw.FontStrikethru [= {True|False}]

[form.]MDraw.FontUnderline [= {True|False}]

Settings

The settings for these properties are:

Setting | Description
True | Turns on the formatting in corresponding style.
False | Turns off the formatting in corresponding style.

Remarks

These properties apply only to text objects.

For more information, see the description of these properties in the Microsoft Visual Basic Language Reference.

Data Type

Integer (Boolean)

See also

Changing object's attributes, FontName property, FontStyle property


FontCharSet Property

Description

This property sets or returns a value determining the character set used to display text in the corresponding text object.

Usage

[form.]MDraw.FontCharSet = setting%

Settings

The FontCharSet property usual settings are:

Constant | Value
ANSI_CHARSET | 0
DEFAULT_CHARSET | 1
SYMBOL_CHARSET | 2
SHIFTJIS_CHARSET | 128
HANGEUL_CHARSET | 129
HANGUL_CHARSET | 129
GB2312_CHARSET | 134
CHINESEBIG5_CHARSET | 136
OEM_CHARSET | 255
JOHAB_CHARSET | 130
HEBREW_CHARSET | 177
ARABIC_CHARSET | 178
GREEK_CHARSET | 161
TURKISH_CHARSET | 162
VIETNAMESE_CHARSET | 163
THAI_CHARSET | 222
EASTEUROPE_CHARSET | 238
RUSSIAN_CHARSET | 204
MAC_CHARSET | 77
BALTIC_CHARSET | 186

Other values may depend on fonts exist in the operating system.

Remarks

The FontCharSet property applies a character set to the object(s) whose handle is specified in .Current property.

The default for this property is determined by the system.

Note: Not all fonts support character sets. If the font does not support the specified character set this setting will be ignored without any errors.

Example

With MetaDraw
    ' Add text object with characters in Russian
    .AddObject  OT_TEXT, 100, 100, 100, 100
    .FontName = "Arial"
    .FontCharSet = 204
    .Text = "Да Здравствует MetaDraw!!!"
End With

See Also

Font… properties, Text Property


FontName Property

Description

Determines the font name for a text object.

Usage

[form.]MDraw.FontName [= font_name$]

Remarks

This property applies only to text objects.

For more information, see the description of the FontName property in the Microsoft Visual Basic Language Reference.

Data Type

String

See also

Changing object's attributes, FontSize property


FontOrient Property

Description

Specifies the angle, in degrees, between the base line of the characters of the text object and the x-axis.

Usage

[form.]MDraw.FontOrient [= angle#]

Remarks

The angle is generally measured counterclockwise from the x-axis. The user can assign negative values to this property. In this case, the angle is measured in a clockwise direction.

For text objects which have been associated as LinkLabels on Lines, Links, or Dimension Lines, the OS_LINKANGLE flag in the OBJStatus property determines whether the angle is relative to the x-axis, or to the angle of the associated Line, Link or Dimension Line

The point around that the text object is rotated depends on the current text alignments that are determined by the TextHAlign and TextHAlign properties.

The FontOrient applies only to TrueType fonts. If the font specified by the FontName property is not TrueType, then this property is ignored and text is painted horizontally.

This property is affected only for a text object.

This property always returns a normalized value in the following range: from -180° upto 180°.

Note: The ObjRotation property can be used instead of this property.

Data Type

Single

See also

Changing object's attributes, FontName property, ObjRotation property


FontSize Property

Description

Determines the font size for a text object.

Usage

[form.]MDraw.FontSize [= font_size#]

Remarks

This property is measured in points (1/72 inch) if the value supplied is positive. If the value is negative, then it's absolute value is used to specify the font size in picture logical coordinates.

This property applies only to text objects.

For more information, see the description of the FontSize property in the Microsoft Visual Basic Language Reference.

Data Type

Single

See also

Changing object's attributes, TextStyle property, FontName property, FontWidth property


FontWidth Property

Description

The FontWidth property sets the fixed width for Text objects so it is independent of the Height of the text as specified by FontSize property

Usage

[form.]MDraw.FontWidth [= font_width#]

Remarks

Setting the FontWidth property to 0 tells that the width of text characters will be calculated automatically according to Font aspect ratio.

See also

FontName property, FontSize property


GetBounds Method

Description

This method returns the boundaries of the object (or selected objects) pointed to by the handle specified in the Current property.

Declaration

Sub GetBounds (Left As Long, Top As Long, Ê
 Ä Right As Long, Bottom As Long, Ê
 Ä ByVal CrdType As Integer)

Syntax

MDrawPro1.GetBounds  left&, top&, right&, bottom&, crdType%

Parameters

The GetBounds method uses these arguments:

Argument | Description
left, top | Long variables where to MetaDraw saves the left-top corner of the bounding rectangle.
right, bottom | Long variables where to MetaDraw saves the right-bottom corner of the bounding rectangle.
crdType% | Specifies the type of coordinates for the left%, top%, right%, bottom% parameters.

Remarks

This method causes a run-time error in case of problems.

The type of coordinates in crdType% can be the following values:

Constant | Value | Description
CRD_LOGIC | 0 | Return the object(s) boundaries in global logical coordinates.
CRD_LOGIC_LOCAL | 2 | All object's coordinates are specified in local (container) logical units.
CRD_PIXELS | 4 | All object's coordinates are returned in client pixels.
CRD_ROTATED | 512 | Including this flag within the crdType% parameter instructs MetaDraw to return boundaries of an object as it is shown rotated in the image. If this flag is not set the GetBounds method will return data for the object in an non-rotated state).

If the Current property specifies a group of selected objects then left%, top%, right%, bottom% will be filled with the boundaries of the rectangle which is the smallest rectangle that contains all the selected objects.

Example:

'  This code draws a dotted frame around the selected objects
Private Sub cmdFrame_Click()
    Dim Left As Long, Top As Long
    Dim Right As Long, Bottom As Long
    '  Assume that some objects are selected at this point
    MDraw.Current = OBJ_SELECTED
    MDraw.GetBounds Left, Top, Right, Bottom, CRD_LOGIC
    MDraw.AddObject OT_RECTANGLE, Left, Top, Right, Bottom
    MDraw.FillStyle = FS_TRANSPARENT
    MDraw.LineStyle = PS_DOT
End Sub

See Also

Logical coordinates, SetBounds method, Current property


GetGrayScaleValue Method

Description

The GetGrayScaleValue method provides a mechanism for reading the average grayscale value (0 to 255) for portion of image within a defined rectangular area.

Declaration

Function GetGrayScaleValue (Left As Long, Top As Long, Ê
 Ä Right As Long, Bottom As Long, Ê
 Ä ByVal CrdType As Integer) As Single

Syntax

MDrawPro1.GetGrayScaleValue  X1&, Y1&, X2&, Y2&, crdType%

Parameters

The GetGrayScaleValue method uses these arguments:

Argument | Description
X1, Y1, X2, Y2 | Coordinates defining rectangular area
crdType% | Specifies the type of coordinates for the X1, Y1, X2, Y2 parameters. crdType% can be one of the following values:
 | Constant | Value | Description
 | CRD_LOGIC | 0 | Return the object(s) boundaries in global logical coordinates.
 | CRD_PIXELS | 4 | All object's coordinates are returned in client pixels.

Returns

The GetGrayScaleValue method returns a value for the average Gray Scale Value of pixels within a defined rectangular area.

Example

' Example 1
' Get Gray Scale value for a specific X, Y location
Value = MetaDraw.GetGrayScaleValue x, y, x, y, CRD_PIXELS
' Example 2
' Get Gray Scale value within area marked by mouse
Dim X1 As Long, Y1 As Long
Sub MDrawPro1_MouseDown(Button As Integer, Shift As Integer, _
                        X As Single, Y As Single)
    X1 = X
    y1 = Y
End Sub

Sub MDrawPro1_MouseUp(Button As Integer, Shift As Integer, _
                      X As Single, Y As Single)
   Dim X2 As Long, Y2 As Long
   x2 = X
   y2 = Y
   Label1.Caption = MDrawPro1.GetGrayScaleValue( _
                    X1, y1, x2, y2, CRD_LOGIC)
End Sub


GetParams, GetParamsEx Methods

Description

The GetParams method fills an array of points, passed in the PointsArray argument, with "Additional Point Parameters " describing the object whose handle is specified in the Current property.

Additional Point Parameters specify the:

  • points of a polyline or a polygon
  • rounded corners in a rounded rectangle
  • starting or ending points of a sector, arc or chord.

The GetParamsEx method works exactly as the GetParams method, but accepts array of Integer, Long or Single values as third (point array) parameter.

Declaration

Function GetParams (ByVal FirstPar As Long, ByVal NumPar As Long, Ê
 Ä ByRef PointsArray As Long, Ê
 Ä ByVal CrdType As Integer) As Long

Function GetParamsEx (ByVal FirstPar As Long, ByVal NumPar As Long, Ê
 Ä ByRef PointsArray As Variant, Ê
 Ä ByVal CrdType As Integer) As Long

Syntax

MDrawPro1.GetParams  FirstParam&, NumPar&, PointsArray&(0), crdType%
MDrawPro1.GetParamsEx  FirstParam&, NumPar&, PointsArray, crdType%

Parameters

The GetParams method uses these arguments:

Argument | Description
FirstPar& | Specifies the first parameter to be retrieved into PointArray. Possible Values for this parameter depend on the object type for which parameters are to be retrieved.
 | LINE: |  | 0, 1 (starting and ending points)
 | ROUNDRECT: |  | 0 - width and height of corner ellipses in units according to the crdType% parameter, 1 - width and height of corner ellipses in 0.01 percent from rectangle width/height (the negative value, -10000, means the full rectangle width/height)
 | SECTOR, ARC, CHORD: |  | 0, 1 - (starting and ending points),
 | POLYLINE, POLYGON: |  | >= 0, the starting point to be read; < 0, the starting point (counted from the endpoint) to be read.
NumPar& | Specifies the number of points to read into PointsArray:
 | < 0, | read the rest of the points (starting beginning from FirstPar&) into PointsArray&
 | = 0, | the function returns the number of available points without actually changing PointsArray&
 | > 0, | read this number of points (starting from FirstPar&) into PointsArray&.
PointsArray& | ( GetParams) An array of points (x and y coordinates pairs which are Long). ( GetParamsEx) An array of points (x and y coordinates pairs which are Long). This may be one or two dimension array of Integer, Long or Single type.
CrdType% | Specifies the type of coordinates for the PointsArray& parameter (see values in the GetBounds method).

Returns

The GetParams function returns the number of POINTS actually written to PointsArray&. When the object is POLYLINE/POLYGON and NumPar& = 0, the function returns the total number of points in the polyline/polygon.

Remarks

This method causes a run-time error if the parameters are invalid.

The Current property must contain a handle of a valid object when calling this method.

Note: NumPar specifies the number of Long pairs (x and y coordinates). Therefore, the dimension of the array PointsArray parameter must be twice the value of NumPar.

Example

' Example 1
' This example assumes the Current object is a polyline object
' Get the number of points (points array is not set here)
Dim res As Long, PointArray(1) As Long
res = MDraw.GetParams(0, 0, PointArray(0), 0)
ReDim PointArray(res * 2) As Long
 ' Read all the points into PointsArray
res = MDraw.GetParams(0, res, PointArray(0), 0)
' Example 2
' This example assumes the Current object is a polygon object
' Read 5 points into PointArray,
' starting at 10th point from the end of Polygon
Dim PointArray (0 to 9) As Long, res As Long
res = MDraw.GetParams(-10, 5, PointArray(0), 0)

See Also

SetParams methods


GotFocus Event

Description

Occurs when the MetaDraw control receives the focus.

Syntax

Sub MetaDRAW_GotFocus ([Index As Integer])

See also

GotFocus event in the Microsoft Visual Basic Language Reference


GradientStyle Property

Description

This property specifies a gradient style to show gradually changing color in the background of the control.

Usage

[form.]MDraw.GradientStyle [= style%]

Remarks

The GradientStyle property settings are:

Constant | Value | Description
GRS_NONE | 0 | (Default) Do not paint gradient background.
CRS_LEFTTORIGHT | 1 | Colors gradually change from the left to right.
CRS_TOPTOBOTTOM | 2 | Colors gradually change from the top to the bottom.
CRS_CENTERHORZ | 3 | Colors gradually change horizontally from the center.
CRS_CENTERVERT | 4 | Colors gradually change vertically from the center.

The initial color (left, top or center) is determined by the PicBackColor property. Right, bottom and edges colors are determined by the PicBorderColor property.

For non-zero GradientStyle settings, MetaDraw fills all client area of the MetaDraw window independently of visible picture sizes.

Data Type

Integer (Enumerated)

See also

PicBackGolor, PicBorderColor properties


GridAlign Property

Description

This property determines whether or not to align object coordinates to the grid while editing.

Usage

[form.]MDraw.GridAlign [= {True|False}]

Remarks

The grid allows the user to align and place objects precisely with the mouse.

When GridAlign is True and you create, move or resize any objects or containers the mouse coordinates will snap to the nearest grid marker.

Note: Alignment to grid can be toggled (enable or disabled) by pressing the CTRL key while dragging the mouse.

Data Type

Integer (Boolean)

See also

Add object using mouse, GridWidth, GridHeight properties, EditMode property


GridColor Property

Description

This property specifies the color of the alignment grid within MetaDraw.

Syntax

[form.]MDraw.GridColor [= RGBColorValue& ]

See also

GridHeight, GridWidth, GridStyle, GridAlign properties


GridHeight, GridWidth Properties

Description

These properties determine the distance between grid markers in picture logical units.

Usage

[form.]MDraw.GridWidth [= x_size&]

[form.]MDraw.GridHeight [= y_size&]

Remarks

The GridWidth and GridHeight properties determine the distance between two neighboring grid markers. They can be assigned values from 1 to PicWidth (x) or PicHeight (y).

Note: The grid may not be displayed when GridWidth or GridHeight is set to such values that the visible distance between two neighboring grid markers less than the size of a resize handle specified by the MarkerSize property.

Data Type

Long

See also

Add object using mouse, GridAlign, GridShow, GridColor, GridStyle properties


GridShow Property

Description

This property determines whether or not to display a grid of regularly spaced points for aligning graphic objects in editing modes.

Usage

[form.]MDrawPro.GridShow [= {0, 1, 2}]

Settings

Constant | Value | Description
GRID_NONE | 0 | No grid is shown
GRID_UNDER | 1 | The grid is shown beneath all other objects and will not be seen behind opaque objects
GRID_ABOVE | 2 | The grid is shown above all objects and will not be hidden by opaque objects.

Remarks

The grid is a set of regularly spaced points, one black screen pixel each. The GridWidth and GridHeight properties specify the distance between these points.

The grid is shown only if the distance between two neighboring grid markers is greater than 5 screen pixels on the x-axis or y-axis. Along with GridWidth and GridHeight, the screen distance between grid points depends upon the current scaling mode (PicXSize,PicYSize and PicWidth,PicHeight properties).

The grid is never shown regardless of the ShowGrid setting if the EditMode is set to ED_VIEW.

Data Type

Integer (Enumerated)

See also

Adding an object using mouse, GridAlign, GridShow, GridColor, GridStyle properties


GridStyle Property

Description

This property controls the presentation style of a Grid within MetaDraw.

Syntax

[form.]MDraw.GridStyle [= Style%]

Settings

Constant | Value | Display Mode
GRIDLINE_DOTS | 0 | Only the dots at the grid points are shown
GRIDLINE_SOLID | 1 | The grid is drawn as solid lines
GRIDLINE_DOTTED | 2 | The grid is drawn as dotted lines
GRIDLINE_DASHED | 3 | The grid is drawn as dashed lines

Default Value

GRIDLINE_DOTS (0)

See also

GridHeight, GridWidth, GridColor, GridAlign properties


hDC Property

Description

This property specifies a handle provided by the Windows Environment to the device context of a MetaDraw picture box. You can use this handle as a parameter in Windows GDI function calls to paint (add) a new object to the picture.

Usage

hDC% = [form.]MDraw.hDC

res = SomeGDICall (hDC%, ...)

[form.]MDraw.hDC = {True|False}

Remarks

The first time this property is read, the MetaDraw control creates a DC for the metafile in memory and returns its handle. Each time thereafter, MetaDraw returns the handle of the previously created metafile DC. You can destroy a previously created DC assigning a value of False (0) to this property.

The first time a metafile DC is created , the origins and extents of the window associated with this device context are set to (PicLeft, PicTop) and (PicWidth, PicHeight) respectively. The mapping mode of DC is set to MM_ANISOTROPIC. In other words, the MetaDraw control adds the following metafile records to the metafile DC after it has been created:

SetMapMode(hDC, MM_ANISOTROPIC)
SetWindowOrg(hDC, PicLeft, PicTop)
SetWindowExt(hDC, PicWidth, PicHeight)

The MetaDraw control also sets the pen, brush and font according to the currently specified global attributes.

Setting this property to True finishes drawing and adds all the new objects to the open container. You can abort the drawing action by assigning False to this property.

Note: This property gives you the unique ability to draw over the pictures of any of the VB-supported types - bitmaps, metafiles and icons. However, to use this possibility, you should understand how Windows GDI functions work. Remember that any technique involving the lower-level Windows APIs is more complex and less safe than the pure-VB programming!

Data Type

Integer (The Device Context handle)

See also

Creating a new object, ExportDC property


Height Property

Description

This standard property contains the height of the MetaDraw control.

Usage

[form.]MDraw.Height [= numeric_expr]

Data Type

Single

See also

Height property in the Microsoft Visual Basic Language Reference


HelpContextID Property

Description

This standard property determines the context number of the Help topic associated with the MetaDraw control.

Usage

[form.]MDraw.HelpContextID [= numeric_expr&]

Data Type

Long

See also

HelpContextID property in the Microsoft Visual Basic Language Reference


HitObject, HitObjectDouble Events

Description

These events are triggered when the mouse is clicked upon a Hitable object

Syntax

Sub MetaDraw_HitObject ([Index As Integer,] ByVal X As Long, ByVal Y As Long)

Sub MetaDraw_HitObjectDouble ([Index As Integer,] ByVal X As Long, ByVal Y As Long)

Remarks

These events are triggered for Hitable objects when:

  • The EditMode property is set to ED_VIEW
  • The left mouse button is clicked on or near the object border or on top of the object fill area (if FillStyle is not FS_TRANSPARENT).

A Hittable object is an object for which the ObjHotSpot property includes the OS_CLICK flag ( can trigger HitObject event) or the OS_DBLCLICK flag ( can trigger HitObjectDouble event).

The X, Y parameters contain mouse pointer coordinates in the MetaDraw client window in pixels. The Index parameter uniquely identifies a control if it is in a control array.

When the HitObject or HitObjectDouble event is triggered, the .Current property contains handle of the topmost "hitable" object in object stacking order and any properties (such as .ObjTag) pertaining to that object may then be read.

To retrieve the Next object under the specified object at the given X/Y Mouse coordinates use the ObjectsHitTest method.

The Modifications property flag MOD_HITTHROUGH determines how hotspots are recognized for containers and objects within containers. With this bit flag set, MetaDraw reacts to the hotspot status of individual objects under the mouse whether the objects are grouped in a container or not. When the MOD_HITTHROUGH flag bit is clear, the hotspot status of objects within a container group are ignored and MetaDraw will react instead to the hotspot settings of the container object. Objects outside of a container are not affected by this Modifications flag setting.

Example:

Sub MetaDraw_HitObject (X As Long, Y As Long)
    ' Read the Tag of the hit object and present
    ' some information or take some action
    MsgBox MetaDraw.ObjTag
End Sub

See also

ObjStatus property, ObjHotSpot property, Current property


HitSensitivity Property

Description

This property determines the a sensitivity or precision to be applied when clicking with the mouse, or when calling the ObjectsHitTests method. Setting the HitSensitivity to a larger value allows the user to select without being as precise when he clicks (for instance it is not necessary to click exactly on a one-pixel wide line to select it), Setting the HitSensitivity to a smaller value allows the user to more precisely control what he clicks on (useful when lines are very close together).

Usage

[form.]MDraw.HitSensitivity = x%

Default Value

The default value for this property is 3 (pixels).

See also

HotSpot property, HitObject event, ObjectsHitTests method


HotSpots Property

Description

This property determines whether MetaDraw changes the mouse cursor and triggers the OnHotSpot event when over a hotspot in EditMode ED_VIEW.

Usage

[form.]MDraw.HotSpots [= {True|False}]

Settings

The HotSpots property settings are:

Setting | Description
False | Disable hotspots abilities.
True | Enable hotspots abilities. (Changing of the mouse pointer and triggering of the OnHotSpot event for Object's where ObjHotSpot is set.

Remarks

The actions specified by the ObjHotSpot property are enabled only in the MetaDraw view mode (when the EditMode property is set to ED_VIEW).

The cursor is changed and the OnHotSpot event is triggered only when:

  • The EditMode property is set to ED_VIEW
  • The HotSpots property is True
  • The mouse is over an object with flags OS_CURSOR or OS_HOTSPOT set in the ObjHotSpot property.

The Modifications property flag MOD_HITTHROUGH determines how hotspots are recognized for containers and objects within containers. With this bit flag set, MetaDraw reacts to the hotspot status of individual objects under the mouse whether the objects are grouped in a container or not. When the MOD_HITTHROUGH flag bit is clear, the hotspot status of objects within a container group are ignored and MetaDraw will react instead to the hotspot settings of the container object. Objects outside of a container are not affected by this Modifications flag setting.

Data Type

Integer (Boolean)

See also

OnHotSpot event, ObjHotSpot property


hPal Property

Description

Determines a logical palette that is used for displaying the current picture.

Usage

[form.]MDraw.hPal [= hPal%]

Remarks

The picture that is displayed in the MetaDraw control window can have its own pallete. A handle to this palette is returned when you read this property. If MetaDraw does not have a palette this property always returns 0.

Note: The palette is only available, if the video driver supports palette mode.

MetaDraw automatically creates a palette, if the MetaDraw's picture contains at least one bitmap object which has a palette. You can change or assign a new palette for the picture at run-time. To do this, use Windows API functions to create a new palette handle and then assign it to the hPal property. All objects' colors will be rendered to the nearest color from the assigned palette.

Note: MetaDraw never changes or deletes the assigned palette, but copies it to its own identical palette. You are also responsible for deleting the original (prototype) palette assigned to MetaDraw. But you should not delete or modify its copy returned by the hPal property.

The following code creates a green tints scale inside the MetaDraw window (cmdScale_Click subroutine) and then attaches green tints palette (cmdPalette_Click subroutine).

Declare Function CreatePalette Lib "GDI.EXE" (pPl As Long) As Integer
Declare Sub DeleteObject Lib "GDI.EXE" (ByVal Handle As Integer)
Sub cmdScale_Click ()
    Dim I%
    ' Change default attributes
    MDraw.Current = OBJ_DEFAULT
    MDraw.LineStyle = PS_NULL    ' no border
    MDraw.FillStyle = FS_SOLID
    ' Create Scale
    For I% = 0 To 235
        ' Create rectangle
        MDraw.AddObject 2, I% * 4 + 20, 200, I% * 4 + 24, 600
        ' Assign various tints of green color
        MDraw.FillColor = RGB(0, I% + 10, 0)
    Next I%
End Sub
Sub cmdPalette_Click ()
    Dim Pal%, I%
    ReDim LogPal(237) As Long
    LogPal(0) = &H300& + 236 * &H10000
    For I% = 1 To 236
        LogPal(I%) = RGB(0, I% + 9, 0)
    Next I%
    ' Call to Windows API function to create a new palette
    Pal% = CreatePalette(LogPal(0))
    ' Assign the palette to MetaDraw
    MDraw.hPal = Pal%
    ' Destroy the palette
    DeleteObject (Pal%)
    ' Refresh MetaDraw window
    MDraw.Refresh
End Sub

Data Type

Integer (The Palette handle)

See also

Creating a new picture


hWnd Property

Description

This standard property returns the handle of the MetaDraw's window.

Usage

hWindow% = [form.]MDraw.hWnd

Data Type

Integer (The Window handle)

See also

hWnd property in the Microsoft Visual Basic Language Reference


Index Property

Description

This standard property specifies a number that uniquely identifies a MetaDraw control in a control array. Available only if the control is part of a control array. Read-only at run time.

Usage

[form.]MDraw.Index

Data Type

Integer

See also

Index property in the Microsoft Visual Basic Language Reference


JPGQuality Property

Description

This property controls the Compression used for saving JPG images. Higher Quality will result in Lower Compression.

Syntax

[form.]MDraw.JPGQuality [= quality_setting%

Settings

Valid settings for this property range from 0 to 100.

100 means highest quality image, 0 is lowest quality ( but highest compression).

The quality and compression of JPG images are related. Higher Quality is achieved with lower compression, and Lower Quality results in Higher Compression. A recommended setting for this property is 70 ( the default value ).

Remarks

This property does not affect loading of JPG images, only Saving.

This property should be set before calling the SavePicture property with PICTYPE_JPGFILE.

Example

With MetaDraw
    .JPGQuality = 70
    .SavePicture "c:\Somefile.jpg", PIC_PICTURE, PICTYPE_JPGFILE
End With

See also

SavePicture property


KeyDown, KeyUp Events

Description

These standard events occur when the user presses (KeyDown) or releases (KeyUp) a key while the MetaDraw control has input focus. (To interpret ANSI characters, use the KeyPress event.)

Syntax

Sub MDraw_KeyDown ([Index As Integer,] KeyCode As Integer, Shift As Integer)

Sub MDraw_KeyUp ([Index As Integer,] KeyCode As Integer, Shift As Integer)

See also

KeyDown and KeyUp events in the Microsoft Visual Basic Language Reference


KeyPress Event

Description

These standard events occur when the user presses and releases an ANSI key.

Syntax

Sub MDraw_KeyPress ([Index As Integer,] KeyAscii As Integer)

See also

KeyPress event in the Microsoft Visual Basic Language Reference


Left, Top Property

Description

These standard properties determine the position of the MetaDraw control inside its container.

Usage

[form.]MDraw.Left [= x]

[form.]MDraw.Top [= y]

Data Type

Single

See also

Left and Top properties in the Microsoft Visual Basic Language Reference


LineColor Property

Description

Determines the color of a line or of an object's border.

Usage

[form.]MDraw.LineColor [= color_expression]

Data Type

Long (Color)

See also

Changing object's attributes, LineStyle property


LineStyle Property

Description

Determines the line style for line and polyline objects or the border style for other objects.

Usage

[form.]MDraw.LineStyle [= setting%]

Settings

The LineStyle property settings are:

Constant | Value | View
PS_SOLID | 0 | _____
PS_DASH | 1 | _ _ _ _
PS_DOT | 2 | . . . . . .
PS_DASHDOT | 3 | _ . _ . _
PS_DASHDOTDOT | 4 | _ . . _ . . _
PS_NULL | 5 | Ignore border
PS_INSIDEFRAME | 6 | Inside Solid. The outer edge of the border is the outer edge of the object. Like PS_SOLID for line, polyline and polygon objects.

The following additional LineStyle property settings may be combined (Logical OR) with the above:

Constant | Value | View
PS_CLOSED | 16 | When applied to a Bezier or Polyline object, closes the curve – connecting the starting and ending points.
PS_ENDCAP_SQUARE | 256 | Use square endings instead of rounded ones for lines and dotted/dashed border segments
PS_ENDCAP_FLAT | 512 | The same as PS_ENDCAP_SQUARE but applied to line ends at the ending point
PS_CORNER_BEVEL | 4096 | Bevel corners of Rectangle borders & polyline/polygon segments corners
PS_CORNER_SQUARE | 8192 | Use square corners in rectangle borders & polyline/polygon segments corners

Remarks

If LineStyle is PS_INSIDEFRAME, the border is drawn inside the object's boundaries (this value is valid only for 'shape' objects: rectangles, ellipse, sectors). If LineStyle is PS_SOLID, the border is centered around the object's boundaries.

Flags PS_ENDCAP_x and PS_CORNER_x settings work under Win NT, 2000, XP only, they are ignored in Win95, Win98 & WinMe.

Note: Non-solid line styles are ignored and the lines are drawn SOLID if the visible line width is greater than one pixel. To guarantee that the line is non-solid, specify LineWidth = 0, which means a pixel width of 1 on a display of any resolution.

Data Type

Integer (Enumerated)

See also

Changing object's attributes, LineWidth property


LineWidth Property

Description

Determines the width of the line or the object border width.

Usage

[form.]MDraw.LineWidth [= width#]

Remarks

The LineWidth property is measured in points (1/72 inch). You can specify the line width in logical picture units if you assign this property a negative value (the absolute value is taken as the width).

To get lines of minimal size on the given device (one pixel), use LineWidth = 0.

Data Type

Single

See also

Changing object's attributes, LineStyle property


LinkFlags Property

Description

In combination with the LinkStyle property, determines how to draw link endings.

Usage

[form.]MDraw.LinkFlags(<index%>) [= flags%]

Remarks

The Index% parameter identifies which link ending is being described.

Constant | Value | Description
LNK_START | 0 | Starting link point
LNK_END | 1 | Ending link point
LNK_BOTH | 2 | Both starting & ending points (for assignment)
LNK_CENTER | 3 | Center Symbol

The values assigned to this property can be a combination (OR) of the following BitFlags:

Constant | Value | Description
LF_SHORT | &H02 | If Set, the link termination is set short of the linked object.
LF_FILLED | &H04 | If Set, the FillStyle property setting of the link object determines the fill style of the link terminator, otherwise the link terminators are transparent.
LF_INVERTED | &H08 | Determines the direction for arrow styles

Data Type

Integer

See also

Changing object's attributes, Current property


LinkLabel Property

Description

Assigns or retrieves a text label to/from the Link, Line, or Dimension Line object whose handle is specified in the Current property.

Setting the LinkLabel with the handle of a text object associates that text object with the Link Label or Dimension Line and automatically moves the text object to the link, and continue to maintain the relative positioning when the line, link or dimension line is moved - for instance for a link if one of the linked objects is moved both the link line and the associated text will be moved automatically.

Reading the LinkLabel returns the handle of the associated text object.

Usage

[form.]MDraw.LinkLabel [= <obj_handle&>]

Remarks

The Current property must contain the handle of the link, line, or dimension line whose label is being assigned or retrieved.

Any text object can be assigned as a label (including multiline and boxed text). Text will be displayed in the middle of Link, Line or Dimension Line according to text object's alignments.

Link label objects cannot be moved using mouse or SetBounds method. They are bound to the labeled object.

The OS_LABELANGLE flag in the ObjStatus property determines whether the display angle of the text object is relative to the link line or to the parent container.

After associating a text object as a LinkLabel, the text object will be automatically deleted if the associated Line, Link or Dimension Line is deleted.

Example

' The following code creates a link between selected objects
' and assigns to this link a text label.
MDraw.AddObject OT_TEXT, 0, 0, 0, 0
MDraw.TextStyle = TXT_MULTILINE
MetaDraw1.TextVAlign = TXT_VCENTER
MetaDraw1.TextHAlign = TXT_CENTER
MDraw.Text = "Text label for a link"
LabHnd& = MDraw.Current  ' Save label handle
MDraw.CreateLink OBJ_SELECTED, OBJ_SELECTED, 0
MDraw.LinkLabel = LabHnd&  ' Assign label
' The following code reads the text associated with a selected link
LabHnd& = MDraw.LinkLabel  ' read the handle of the link label object
If labHnd& >0 Then
    MDraw.Current = LabHndl&   ' point to the link label object
    Print "the text associated with this link is" & MDraw.Text
End If

Data Type

Long

See also

CreateLink method, ObjStatus property,
Changing object's attributes, How to create and manipulate diagram links


LinkLength, LinkWidth Properties

Description

Determines length and width of the link endings.

Usage

[form.]MDraw.LinkLength(<index%>) [= length#]

[form.]MDraw.LinkWidth(<index%>) [= width#]

Remarks

The assigned values for these properties are measured in points.

The Index% parameter identifies which link ending is being set or read:

Constant | Value | Description
LNK_START | 0 | Starting link point
LNK_END | 1 | Ending link point
LNK_BOTH | 2 | Both starting & ending points (for assignment)
LNK_CENTER | 3 | Center Symbol

Data Type

Single

See also

Changing object's attributes, Current property


LinkObject Property

Description

Determines which object a link ending is connected to.

Usage

[form.]MDraw.LinkObject(<index%>) [= handle&]

Remarks

The Index% parameter determines which link ending is described :

Constant | Value | Description
LNK_START | 0 | Object the link begins from
LNK_END | 1 | Object the link points to

Data Type

Long (Object handle)

See also

Changing object's attributes, Current property


LinkStyle Property

Description

Determines whether to draw arrow heads or other markers at the connection points and/or center of a link.

The LinkStyle property may also be applied to an Arc, Line, PolyLine or Dimension Line, but center markers can only be drawn on links and dimension lines ( not arcs, lines, polylines)

Usage

[form.]MDraw.LinkStyle(<index%>) [= style%]

Remarks

The Index% parameter identifies which link ending is being set or read:

Constant | Value | Description
LNK_START | 0 | Starting link point
LNK_END | 1 | Ending link point
LNK_BOTH | 2 | Both starting & ending points (for assignment)
LNK_CENTER | 3 | Center Symbol ( Center Symbol may be applied only to Dimension Lines and Links)

Values which may be assigned to the LinkStyle property settings include:

Constant | Value | Description
LS_NONE | 0 | no shape defined for the corresponding link endings.
LS_RECTANGLE | 1 |
LS_DIAMOND | 2 |
LS_OCTAGON | 3 |
LS_ELLIPSE | 4 |
LS_OPENARROW | 5 |
LS_STEALTHARROW | 6 |
LS_FILLARROW | 7 |
LS_PERLINE | 8 |
LS_PERARROW | 9 |
LS_CROSS | 10 | ––X––

Data Type

Integer (Enumerated)

Example

' create a link between selected objects and set characteristics
MetaDraw.CreateLink OBJ_SELECTED, OBJ_SELECTED, 0
MetaDraw.LinkStyle (LNK_BOTH) = LS_PERLINE
MetaDraw.LinkStyle ( LNK_CENTER) = LS_CROSS

See Also

Changing object's attributes, Current property


LinkSymbolColor Property

Description

Sets/returns the color of the specified link symbol.

Usage

[form.]MDraw. LinkSymbolColor (<link_ending%>) [ = <color&>]

Remarks

The Current property must contain the handle of the link whose symbol color is retrieved/changed.

The index value specifies which link ending symbol should be changed. It is possible to change both starting and ending symbol colors at one time (LNK_BOTH value).

The link_ending% values are:

Constant | Value | Description
LNK_START | 0 | Symbol at start of link
LNK_END | 1 | Symbol at end of link
LNK_BOTH | 2 | Both starting and ending symbols, also applies to center marker if displayed for DimLines and Links). Use for assignment only.
LNK_CENTER | 4 | Symbol in the middle of the link

Data Type

Long (color)

See also

Link attributes, Changing object's attributes, Current property


LoadData Method

Description

Loads MetaDraw contents from a file.

Syntax

Sub LoadData (ByVal FileName As String)

Remarks

This function loads all MetaDraw data from the specified file (.MDR format), including control window sizes, attributes, all pictures, hotspot definitions, etc.

The MetaDraw contents can also be loaded in design-time using the "Load From…" verb.

See Also

SaveData property


LoadPicture Method

Description

Loads a picture from a specified source (file, database, URL, byte array).

Declaration

Function LoadPicture (ByVal Source As Variant, ByVal PicDst As Integer Ê
Ä [, ByVal PicType As Integer]) As Integer

Syntax

MetaDRAW.LoadPicture Source, picDst%, picType%

Parameters

The LoadPicture method uses these arguments:

Argument | Description
Source | Specifies a source from which picture will be loaded. This is a variant and it may be one of the following types:
 | Source | Type
 | String | A local file name or an URL.
 | Integer | A valid VB file number (see the VB Open statement)
 | Long | A valid (opened) Windows file handle
 | DAO field | A valid field object of DAO Recordset.
 | ADO field | A valid field object of ADO Recordset.
 | RDO column | A valid column object of RDO Resultset
 | ByteArray | A memory byte array that contains binary data of a picture
 | See comments in remark section.
picDst% | Determines destination to which the picture should be assigned. This parameter can take on the following values:
 | Constant |  | Value |  | Description
 | PIC_PICTURE |  | 0 |  | Load into the Picture property - replaces entire picture.
 | PIC_PICTUREIMAGE |  | 1 |  | Load into PictureImage - puts loaded picture into PictureImage buffer.
 | PIC_PICTURECLIP |  | 2 |  | Load as the PictureClip property - merges loaded picture into main picture
 | PIC_PICTURECURRENT |  | 3 |  | Replace objects specified in the current property with the loaded picture.
 | PIC_BACKIMAGE |  |  |  | * RESERVED for Internal MetaDraw use.
 | PIC_BACKPICTURE |  | 4 |  | Load into BackPicture (ICO, WMF, EMF & BMP only)
 | PIC_FILLPATTERN |  | 5 |  | Sets the FillPattern (ICO, WMF, EMF & BMP only)
 | PIC_MOUSECURSOR |  | 6 |  | Sets the Mouse Cursor (ICO only)
picType% | Determines type of loaded picture. Use the following values:
 | Constant |  |  | Value |  | Description
 | PICTYPE_DEFAULT |  |  | 0 |  | Detect picture type automatically.
 | PICTYPE_BITMAP |  |  | 1 |  | Load picture as bitmap.
 | PICTYPE_METAFILE |  |  | 2 |  | Load picture as metafile.
 | PICTYPE_ICON |  |  | 3 |  | Load picture as icon.
 | PICTYPE_ENHMETAFILE |  |  | 4 |  | Load EMF (enhanced Metafile).
 | PICTYPE_INTERNAL |  |  | 10 |  | Load MetaDraw Internal format.
 | PICTYPE_DXFFILE |  |  | 13 |  | Load DXF format. ( requires DXF support License option)
 | PICTYPE_JPGFILE |  |  | 14 |  | Load picture as JPeg
 | PICTYPE_PNGFILE |  |  | 20 |  | Load picture as PNG

Returns

This method returns the type of loaded picture,
or causes a trappable run-time error in case of problems.

Remarks

The LoadPicture method supports the following file formats: .BMP, .DIB, .ICO, .WMF, .EMF, .JPG, .GIF, PNG, .MDP (MetaDraw internal picture format). DXF format is supported for developers with the DXF License option. For support of other file formats, Bennet-Tec can recommend the use of other 3rd party components which work with MetaDraw, or can take on paid support projects to add file formats to meet your needs.

Generally a picType% setting of PICTYPE_DEFAULT is most appropriate, allowing MetaDraw to identify the image type automatically.

Note: The File Extension portion of the file name does not affect how Metadraw loads an image. When loading a picture, you can force interpretation of the picture according to a desired format using the PicType% parameter, or allow MetaDraw to recognize the file type automatically according to the internal format (if picType% is omitted or equal to PICTYPE_DEFAULT)..

Specifying an empty string or unassigned variant as the first parameter of the LoadPicture method will clear the target picture.

Loading From an Image File

To load from an image file simply specify the FileName as the first parameter of the LoadPicture Method

Loading from an Open Sequential File

Specifying a valid open sequential file handle as the source parameter loads a picture from the current position of the opened file This technique is useful to load pictures from picture libraries (several pictures saved in one file).

Note: The MetaDraw 2 LoadPictureFromFile method is obsolete and should not be used.

Loading from a URL

The picture source file can be located on local disk or on a remote server. MetaDraw can load pictures via the Internet using HTTP or FTP protocols. MetaDraw automatically determines which protocol to use when loading a file (by http:// or ftp:// prefixes specified in URL). If remote server that contains loaded picture requires authorization you may specify login information in URL in the following format:

http://[<username>[:<password>]@]www.server.com/...
ftp://[<username>[:<password>]@]ftp.server.com/...

<password> or both <username> and <password> can be omitted if no authorization is required.

Loading from a Database

MetaDraw is able to load pictures directly from database table fields. The referred fields/columns of database table should have long binary value types. Any picture formats supported by MetaDraw can be loaded from or stored to database field (pictures are stored as a byte binary array).

MetaDraw LoadPicture compared to VB LoadPicture loading from a file

The behavior of MetaDraw's internal LoadPicture method when loading from a file is similar to assigning pictures created by the VB LoadPicture statement to the corresponding MetaDraw's picture properties. Using MetaDraw's LoadPicture method instead of the Visual Basic LoadPicture statement allows you to use additional file formats (.MDP, PNG, .DXF,) that are not supported by the VB LoadPicture statement. MetaDraw's LoadPicture method preserves bitmap color resolution (MetaDraw keeps bitmaps in Device Independent format), while the Visual Basic LoadPicture statement will always convert all loaded bitmaps according to the current color resolution. The following table shows values of the picDst% parameter and the equivalent VB LoadPicture statements:

Value of picDst% | Corresponding LoadPicture statement
PIC_PICTURE | MDraw.Picture = LoadPicture ("filename.ext")
PIC_PICTURECLIP | MDraw.PictureClip = LoadPicture ("filename.ext")
PIC_PICTUREIMAGE | MDraw.PictureImage = LoadPicture ("filename.ext")
PIC_BACKPICTURE | MDraw.BackPicture = LoadPicture ("filename.ext")
PIC_FILLPATTERN | MDraw.FillPattern = LoadPicture ("filename.ext")

Example

' Insert icon from a file into the open container
MDraw.LoadPicture "c:\tmp\iconfile.ico", PIC_PICTURECLIP
' Change fill pattern for the current object
MDraw.LoadPicture "e:\Patterns\cross.bmp", PIC_FILLPATERN
' Assign picture to the temporary image and
' then add that image into current open container
MDraw.LoadPicture "e:\Pict\object.mdp", _
        PIC_PICTUREIMAGE, PICTYPE_INTERNAL
MDraw.AddObject OT_IMAGE, 100, 100, 100, 100
' Load picture from the specified URL and use as a fill pattern
MDraw.LoadPicture "http://www.bennet-tec.com/cross.bmp", _
         PIC_FILLPATERN, PICTYPE_BITMAP
' Load picture from a ADO database field
MetaDraw.LoadPicture recADO.Fields("PictureData"), _
         PIC_PICTURE, PICTYPE_DEFAULT
' Load picture from a file to a Byte Array and
' then read byte array into MetaDraw
' Read data from file to Byte array
SourceFile = FreeFile
Open dlgFiles.FileName For Binary As SourceFile
ReDim ByteArr(LOF(SourceFile))
Get SourceFile, , ByteArr()
Close SourceFile
' LoadPicture from byte array to MetaDraw
MetaDraw.LoadPicture ByteArr, PIC_PICTURE

See Also

Loading pictures, SavePicture method


LoadPictureEx Method

Description

*** THIS METHOD IS OBSOLETE, USE LOADPICTURE METHOD INSTEAD


LoadPictureFromFile Method

Description

*** THIS METHOD IS OBSOLETE, USE LOADPICTURE METHOD INSTEAD


LogicToClientX, LogicToClientY Properties

Description

These properties provide a way to convert a point from logical picture coordinates of the picture in the MetaDraw control to the client area coordinates of the control (in pixels).

Usage

nClientX& = MDraw.LogicToClientX(nPicX&)

nClientY& = MDraw.LogicToClientY(nPicY&)

Remarks

Refer to ClientToLogicX, ClientToLogicY properties for more information.

Data Type

Integer


LostFocus Event

Description

This standard event occurs when the MetaDraw control loses focus.

Syntax

Private Sub MetaDRAW_LostFocus ([Index As Integer])

See also

LostFocus event in the Microsoft Visual Basic Language Reference


MarkerColor Property

Description

The MarkerColor property determines the colors used by MetaDraw to set indication markers as used in indicating Selection, Polyline and Link Vertices and Link Connection Points.

Usage

[form.]MDraw.MarkerColor ( Index%) = RGBColor&

Parameters

The Index% parameter identifies which type of marker is being set or read.

The values for Index% are shown below along with the Marker Type each specifies and the default color for each marker type.

Constant | Value | Marker Type | Default Color
MCOL_SELECTION | 0 | Single selection markers |  | White
MCOL_MULTISELECTION | 1 | Multiple object selection markers (used when multiple objects are selected) |  | Light Gray
MCOL_POINTS | 2 | Special object points (used for polyline vertex points, sector endings, round rect ellipses, text alignment, rotation points) |  | Yellow
MCOL_FIXEDLINK | 3 | Fixed link connection point. This color is also used for rotation center marker. |  | Green
MCOL_AUTOLINK | 4 | Automatic link connection points |  | Blue

Data Type

Long

See also

MarkerSize property, Editing modes


MarkerSize Property

Description

This property determines the size of selection markers in pixels (or in points in MetaDraw).

Usage

[form.]MDraw.MarkerSize [= mrk_size%]

Remarks

If the MarkerSize property is set to zero, the markers would not be drawn, and mouse functions that use markers (like resize object) will not available.

MetaDraw allows users to set this property in points (when the value is positive). It is useful when you want to specify the marker size independent of the current screen resolution. You can specify the marker size in pixels if you assign this property a negative value (the absolute value is taken as the size).

The Setting of the MarkerSize also affects the minimum GridSpacing Grids will not be show if the GridHeight or GridWidth is less than the MarkerSize in pixels

Note: Markers don't change their sizes when the MetaDraw picture is zoomed.

Data Type

Single

See also

Editing objects


MDDataObject Object

Description

The MDDataObject object is a container for data being transferred from an component source to an component target. The data is stored in the format defined by the method using the MDDataObject object.

Remarks

The DataObject, which mirrors the IDataObject interface, allows OLE drag and drop and clipboard operations to be implemented. The DataObject is passed as a parameter of OLE DragDrop events.

See also

OLE Drag & Drop techniques, OLEStartDrag, OLESetData events


MDDataObject.Clear Method

Description

Removes all data and defined formats (and the corresponding data) in the DataObject object.

Usage

Sub MDDataObject.Clear ()

Remarks

This method is available only for component drag sources. If Clear is called from a component drop target, an error is generated.

The method can be used in the OLEStartDrag event to remove all default formats and then define new format available for drag operation.

See also

OLE Drag & Drop techniques, OLEStartDrag event


MDDataObject.GetData Method

Description

Returns a graphic picture from the DataObject object in the form of a variant.

Usage

Function MDDataObject.GetData ([ByVal format As Long]) As Variant

Parameters

Parameters of the GetData method are:

Parameter | Description
Format& | Optional. A constant or value that specifies the data object graphics format. If format% is 0 or omitted, GetData automatically uses the appropriate format. MetaDraw supports the following data formats:
 | Constant | Value | Description
 | vbCFText | 1 | Text
 | vbCFBitmap | 2 | Bitmap (.bmp files)
 | vbCFDIB | 8 | Device-independent bitmap (.bmp files)
 | vbCFMetafile | 3 | Metafile (.wmf files)
 | vbCFEMetafile | 14 | Enhanced metafile (.emf files)
 | mdCFMetaDraw | 10 | Internal MetaDraw picture (.mdp files)
 | vbCFFiles | 15 | List of files

Returns

Returns a StdPicture object filled with the expected format.

If mdCFMetaDraw format is requested the method returns interface to a MDPicture object.

If no graphic on the data object matches the expected format, nothing is returned.

Remarks

It's possible for the GetData and SetData methods to use data formats other than those listed above, including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. However, there are a few caveats:

  • The SetData method requires the data to be in the form of a byte array when it does not recognize the data format specified.
  • The GetData method always returns data in a byte array when it is in a format that it doesn't recognize.
  • The byte array returned by GetData will be larger than the actual data when running on some operating systems, with arbitrary bytes at the end of the array.

See also

OLE Drag & Drop techniques, MDDataObject object


MDDataObject.GetFormat Method

Description

Returns a Boolean value indicating whether an DataObject object contains data with the specified format.

Usage

Function MDDataObject.GetFormat (ByVal format As Long) As Boolean

Parameters

Parameters of the GetFormat method are:

Parameter | Description
Format& | An integer value or constant that specifies the data object format. MetaDraw supports the following data formats:
 | Constant | Value | Description
 | vbCFText | 1 | Text
 | vbCFBitmap | 2 | Bitmap (.bmp files)
 | vbCFDIB | 8 | Device-independent bitmap (.bmp files)
 | vbCFMetafile | 3 | Metafile (.wmf files)
 | vbCFEMetafile | 14 | Enhanced metafile (.emf files)
 | mdCFMetaDraw | 10 | Internal MetaDraw picture (.mdp files)
 | vbCFFiles | 15 | List of files

Returns

The GetFormat method returns True if the specified data format is present in a data object. Otherwise, it returns False.

Remarks

Format& can also be any user-defined format registered with Windows via the RegisterClipboardFormat() API function.

See also

OLE Drag & Drop techniques, MDDataObject object


MDDataObject.SetData Method

Description

Inserts data into a DataObject object using the specified data format.

Usage

Sub MDDataObject.SetData ([data As Variant], [ByVal format As Long])

Parameters

Parameters of the SetData method are:

Parameter | Description
data | Optional. A variant containing the data to be passed to the DataObject object.
Format& | Optional. A constant or value that specifies the format of the data being passed to the DataObject object. MetaDraw supports the following data formats:
 | Constant | Value | Description
 | vbCFText | 1 | Text
 | vbCFBitmap | 2 | Bitmap (.bmp files)
 | vbCFDIB | 8 | Device-independent bitmap (.bmp files)
 | vbCFMetafile | 3 | Metafile (.wmf files)
 | vbCFEMetafile | 14 | Enhanced metafile (.emf files)
 | mdCFMetaDraw | 10 | Internal MetaDraw picture (.mdp files)
 | vbCFFiles | 15 | List of files

Remarks

The data argument is optional. This allows you to set several different formats that the source component can support without having to load the data separately for each format. Multiple formats are set by calling SetData several times, each time using a different format. If you wish to start fresh, use the Clear method to clear all data and format information from the DataObject.

The format& argument is also optional, but either the data or format& argument must be specified. If data is specified, but not format&, then MetaDraw will try to determine the format of the data (based on supported formats). If it is unsuccessful, then an error is generated. When the target requests the data, and a format was specified, but no data was provided, the source's OLESetData event occurs, and the source can then provide the requested data type.

It's possible for the GetData and SetData methods to use data formats other than those listed above, including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. However, there are a few caveats:

  • The SetData method requires the data to be in the form of a byte array when it does not recognize the data format specified.
  • The GetData method always returns data in a byte array when it is in a format that it doesn't recognize.
  • The byte array returned by GetData will be larger than the actual data when running on some operating systems, with arbitrary bytes at the end of the array.

See also

OLE Drag & Drop techniques, MDDataObject object


MDDataObject.GetPicture Method

Description

Returns a graphic picture from the DataObject object (this method is an extension of standard DataObject).

Usage

Function MDDataObject.GetPicture ([ByVal format As Long]) As StdPicture

Parameters

Parameters of the GetPicture method are:

Parameter | Description
format% | Optional. A constant or value that specifies the graphics format. If format& is 0 or omitted, GetPicture automatically uses the appropriate format available in the MDDataObject object. Only the following formats can be specified in the GetPicture method:
 | Constant | Value | Description
 | vbCFBitmap | 2 | Bitmap (.bmp files)
 | vbCFDIB | 8 | Device-independent bitmap (.bmp files)
 | vbCFMetafile | 3 | Metafile (.wmf files)
 | vbCFEMetafile | 14 | Enhanced metafile (.emf files)

Returns

Returns a StdPicture object filled with the expected picture format.

If no graphic on the MDDataObject object matches the expected format, nothing is returned.

See also

OLE Drag & Drop techniques, MDDataObject object, GetData method


MDDataObject.SetPicture Method

Description

Inserts the specified picture into a DataObject object (this method is an extension of standard DataObject).

Usage

Sub MDDataObject.SetPicture (ByVal data As StdPicture)

Parameters

Parameters of the SetPicture method are:

Parameter | Description
data | A picture object containing the data to be passed to the DataObject object.

Remarks

If DataObject already contain data for the specified format they will be destroyed.

See also

OLE Drag & Drop techniques, MDDataObject object


MDDataObject.Files Property

Description

Returns a MDDataObjectFiles collection, which in turn contains a list of all filenames used by a MDDataObject object (such as the names of files that a user drags to or from the Windows File Explorer).

Usage

FileName$ = [form].MDDataObject.Files (index%)

Remarks

The Files collection is filled with filenames only when the MDDataObject object contains data of type vbCFFiles (The MDDataObject object can contain several different types of data.) You can iterate through the collection to retrieve the list of file names.

The Files collection can be filled to allow MetaDraw applications to act as a drag source for a list of files.

See also


MDPicture Property

Description

This property is used to copy a picture between two instances of MetaDraw.

Usage

MetaDraw1.MDPicture = MetaDraw2.MDPicture

Remarks

The Picture property of MetaDraw is a stock property which can not hold all the details which may be represented within a MetaDraw image. Using the MDPicture property to transfer an image from one MetaDraw control to another retains the full details.


Modifications Property

Description

This property is used to allow Bennet-Tec to make modifications to MetaDraw to resolve certain "problems" or enhance the behavior of MetaDraw without changing the behavior of existing (already compiled) MetaDraw applications.

Usage

MetaDraw.Modifications = <value%>

Remarks

This is a BitFlag property - it should be set by OR combination of the desired flags

Constant | Value | Description
MOD_OLD | 0 |
MOD_DONTUSEBORDERSIZE | 1 | Don't use object's borders when calculating picture size while exporting/printing. E.g. you want to print one object with wide border, then if this flag is set MetaDraw will print only area determined by object's boundaries, so half of borders will be cut out. If this flag is not set the entire borders will be included in printed area.
MOD_REALCOORDS | 2 | If this flag is set MetaDraw inserts new picture with its real physical size and the picture will not be squeezed even if its size is larger that current picture size. Otherwise inserted picture will be squeezed to fit to the current picture.
MOD_NOCLIPTEXT | 4 | If this flag is set MetaDraw will not clip text on text object boundaries, so some characters can be outside the object boundaries. Setting this bit resolves a problem with presentation of text having a Boxed Style - without this flag text is truncated at the last character
MOD_GROUPCURRENT | 8 | If this flag is set MetaDraw will group (Action = ACT_GROUP) objects whose handle is specified in the Current property. Otherwise all selected objects will be grouped. This allow you to create a new container with only one object inside.
MOD_HITTHROUGH | 16 | If this flag is set MetaDraw will trigger OnHotSpot and HitObject even for objects grouped in containers. Otherwise these events will be triggered only if the whole container is a hotspot. This flag tells MetaDraw that all containers are transparent and the events will be triggered for non-container objects only.
MOD_RESIZESINGLE | 32 | If this flag is set, MetaDraw will prevent users from resizing objects that do not have the OS_Resizible flag set in the ObjStatus property. Normally ( with this flag not set) users can resize any object.


MouseCursor Property

Description

Defines the mouse cursor shape when MousePointer property is MPTR_USER.

Usage

[form.]MDraw.MouseCursor = LoadPicture("...")

Remarks

Use this property to provide customized cursors.

When you load an icon from an .ICO file and then use it as a cursor, the icon image is converted to monochrome and the hot-spot is set to its default position at the middle of the image.

Note: Remember that the Visual Basic (version 3.0) does not allow you to load actual cursors (defined in .CUR files) with the LoadPicture() function.

Data Type

Picture

See also

DragIcon property, MousePointer property


MouseDown and MouseUp Events

Description

These standard events occur when the user presses (MouseDown) or releases (MouseUp) a mouse button over the MetaDraw control.

Syntax

Private Sub MetaDRAW_MouseDown ([Index As Integer,] Button As Integer, Ê
Ä Shift As Integer, X As Single, Y As Single)

Private Sub MetaDRAW_MouseUp ([Index As Integer,] Button As Integer, Ê
Ä Shift As Integer, X As Single, Y As Single)

See also

MouseDown and MouseUp events in the Microsoft Visual Basic Language Reference


MouseMove Event

Description

This standard event occurs when the user moves the mouse pointer over the MetaDraw control.

Syntax

Private Sub MetaDRAW_MouseMove ([Index As Integer,] Button As Integer, Ê
Ä Shift As Integer, X As Single, Y As Single)

See also

MouseMove event in the Microsoft Visual Basic Language Reference


MousePointer Property

Description

Determines the type of mouse pointer, which will be used inside the MetaDraw control.

Usage

[form.]MDraw.MousePointer [= settings%]

Settings

The MousePointer property settings are:

Constant | Value | Description
MPTR_DEFAULT | 0 | (default) Shape determined by the edit mode.
MPTR_ARROW | 1 | Arrow
MPTR_CROSS | 2 | Cross
MPTR_HBEAM | 3 | I-Beam
MPTR_ICON | 4 | Icon
MPTR_SIZE | 5 | Size
MPTR_SIZENESW | 6 | Size NE SW
MPTR_SIZENS | 7 | Size N S
MPTR_SIZENWSE | 8 | Size NW SE
MPTR_SIZEWE | 9 | Size W E
MPTR_UPARROW | 10 | Up arrow
MPTR_HOURGLASS | 11 | Hourglass (wait)
MPTR_NODROP | 12 | No drop
MPTR_USER | 15 | The shape of the mouse pointer is determined by the MouseCursor property
MPTR_MOVE | 16 | Moving an object
MPTR_SCROLL | 17 | Scrolling
MPTR_HOTSPOT | 18 | HotSpot
MPTR_DRAWPEN | 19 | Drawing freeform
MPTR_EDSTART | 20… | Shapes for different edit modes
MPTR_ROTATEOBJ | 53 | Rotating an object

Remarks

The MousePointer property controls the shape of the mouse pointer. This property is useful when you want to indicate changes in functionality as the mouse pointer passes over the control.

It is possible to change the shape of the mouse pointer to the cursor, that is shown for different edit modes, independent of the current edit mode. To do that, set the MousePointer property to
MPTR_EDSTART (20) + ED_xxxx
where ED_xxxx the constant of the corresponding edit mode.

Example

' This code sets the edit mode for MetaDraw to "view mode",
' but the cursor shape will be the same as for "edit mode"
MDraw.EditMode = ED_VIEW
MDraw.MousePointer = MPTR_EDSTART + ED_SELECT

Data Type

Integer (Enumerated)

See also

MouseCursor property


MouseWheel Event

Description

This event allows the application customized control over MouseWheel support.

Syntax

Sub MDrawPro_MouseWheel ([Index As Integer,] _
Ä ByVal Button As Integer, ByVal Shift As Integer, Delta As Integer _
 Ä ByVal X As Single, ByVal Y As Single)

Remarks

The MouseWheel event will be always generated when mouse wheel is rotated.

Note: Depending of installed mouse driver on some Windows OS MetaDraw control should have focus to handle this event.

See also

Scrolling, Zooming, ScrollMouse property


Move Method

Description

This standard method moves and/or resized the MetaDraw control.

Syntax

MDraw.Move left[, top[, width[, height]]]

See also

Move method in the Microsoft Visual Basic Language Reference


MoveObjects method

Description

This method moves the object(s), referenced by the Current property, by specified offsets.

Declaration

Function MoveObjects (ofsX As Long, ofsY As Long, Ê
Ä ByVal crdType As Integer)

Syntax

MetaDRAW.MoveObjects ofsX%, ofsY%, crdType%

Parameters

The MoveObjects method uses these arguments:

Argument | Description
ofsX, ofsY | Specifies offset by which object(s) should be moved. It must be a variable name.
CrdType% | Specifies the type of coordinates for the ofsX and ofsY parameters.

Returns

1 – Indicates object(s) can be moved (if crdType = CRD_CHECK flag)
or object(s) has (have) been moved (if crdType = CRD_SET flag).
0 – Indicates object(s) can not be moved.

Remarks

This method causes a run-time error in case of problems.

The type of coordinates in crdType% can be the following values:

Constant | Value | Description
CRD_LOGIC | 0 | Offsets are in global logical coordinates.
CRD_LOGIC_LOCAL | 2 | Offsets are specified in local (container) logical units.
CRD_PIXELS | 4 | Offsets are specified in client pixels.

The type of coordinates in crdType% can be combined with one of the following values:

Constant | Value | Description
CRD_CHECK | &H200 | Check offsets while moving object. If this flag is specified, MetaDraw will check moved objects such as any part of objects should be inside the picture (inside the rectangle that is determined by the PicLeft, PicTop, PicWidth, PicHeight properties).
CRD_SET | &H400 | Set new boundaries after move object. If this flag is not set, objects are not really moved, just ofsX%, ofsY% are filled with proper values.
CRD_CHANGE | &H600 | Set new boundaries after move with checking (see CRD_CHECK).

Upon completion, if crdType% had the CRD_CHECK flag, the parameters ofsX and ofsY will contain the maximum allowed value for the offsets.

If the Current property points to several selected objects, all of them will be moved by the same offsets (specified in the ofsX and ofsY parameters).

Note: The ofsX and ofsY variables MUST be initialized before calling this method.

Example

' This code inserts a picture from a file and moves
' it to the center of visible area.
Private Sub cmdInsert_Click()
    Dim ofsX As Long, ofsY As Long
    Dim cntX As Long, cntY As Long
    MDraw.PictureClip = LoadPicture("c:\tmp\1.wmf")
    ' The .Current property contains the handle of
    ' the inserted picture
    cntX = MDraw.ClientToLogicX(MDraw.ClientWidth(2) / 2)
    cntY = MDraw.ClientToLogicY(MDraw.ClientHeight(2) / 2)
    ' (cntX, cntY) is the center of the visible area
    ' in logical units
    ofsX = cntX - (MDraw.ObjLeft + MDraw.ObjRight) / 2
    ofsY = cntY - (MDraw.ObjTop + MDraw.ObjBottom) / 2
    ' Move the object
    MDraw.MoveObjects ofsX, ofsY, CRD_LOGIC + CRD_CHANGE
End Sub

See Also

Logical coordinates, Current property, SetBounds method


Name Property

Description

This standard property specifies the name that must be used in code to refer to the MetaDraw control. Not available at run time.

See also

Name property in the Microsoft Visual Basic Language Reference


NoiseReduction Method

!!! This feature requires MetaDraw Vectorization License Option !!!

Description

Noise Reduction removes stray spots which may be accidentally introduced to an image by processes such as scanning.

MetaDraw recognizes "Noise" as single color regioins whose size is less than XNoise bitmap pixels in X-direction and YNoise bitmap pixels in Y-directions.

Declaration

Function NoiseReduction (ByVal Picture As Picture, Ê
Ä ByVal XNoise As Long, Ê
Ä ByVal YNoise As Long) As Picture

Parameters

The NoiseReduction method uses these arguments:

Argument | Description
Picture | Picture object that contains original bitmap.
XNoise&, YNoise& | Size of points with the same colors that should be removed.

Returns

The method returns a new raster (bitmap) picture with the noise removed

In case of errors (DLL not found or input is not a-Raster image) the function returns a null picture.

Remarks

Before vectorizing an image it is recommended to remove noise.

This function applies only to raster images (BMP, JPG, PNG) before conversion to vector format).

Example

xNoise = 2   ' measured in pixels
yNoise = 2
MetaDraw.Picture = MetaDraw.NoiseReduction ( Picture1.Picture, _
                   XNoise , YNoise )

See also

Vectorization Method, NoiseReduction Method


ObjBottom, ObjLeft, ObjRight, ObjTop Properties

Description

These properties determine the logical coordinates of the boundaries of an object or group of objects.

Usage

left& = [form.]MDrawPro.ObjLeft

top& = [form.] MDrawPro.ObjTop

right& = [form.] MDrawPro.ObjRight

bottom& = [form.] MDrawPro.ObjBottom

Remarks

These properties determine the bounding rectangle, in logical picture coordinates, for the object specified by the Current property. If Current specifies a group of objects (selected objects), the bounding rectangle is the smallest rectangle that contains all specified objects.

Use the MetaDraw control mouse editing tools to change object boundaries. Also, the user can receive the objects' bounding rectangle using the GetBounds() method.

Example:

'  This code draws a dotted frame around the selected objects
Private Sub cmdFrame_Click()
    '  Assume that some objects are selected at this point
    MDraw.Current = OBJ_SELECTED
    MDraw.AddObject OT_RECTANGLE, MDraw.ObjLeft, MDraw.ObjTop, _
                MDraw.ObjRight, MDraw.ObjBottom
    MDraw.FillStyle = FS_TRANSPARENT
    MDraw.LineStyle = PS_DOT
End Sub

Data Type

Long

See also

Editing objects, Logical coordinates, GetBounds() method, Current property


ObjCount Property

Description

This property returns the number of objects.

Usage

number_objects = [form.]MDraw.ObjCount(object_type%)

Settings

The parameter can be one of the following values:

Constant | Value | Description
OBJ_CONTAINER | 1 | Returns the number of objects within the open container.
OBJ_SELECTED | 2 | Returns the number of selected objects.
OBJ_CURRENT | 4 | Use Current property for specified container for which Count function is applied.
OBJ_CONT_MAIN | 5 | Returns total number of objects in the picture including objects inside containers (containers are counted as a separate object).

Remarks

Except for the OBJ_CONT_MAIN value, the ObjCount property returns the number of objects that are in the same object's list (container is a solid object).

Data Type

Long

See also

Current property


ObjectHitMarker Method

Description

This method finds the first (bottom most in z-order) selected object in currently opened container and finds out if any its markers lies at the specified coordinates.

Declaration

Function ObjectsHitMarker (Xpos As Long, Ypos As Long, Ê

Ä crdType As Integer) As Long

Syntax

res% = MetaDraw.ObjectHitMarker ( Xpos&, Ypos&,, crdType% )

Parameters

The ObjectHitMarker method has the following parameters:

Argument | Description
Xpos, Ypos | Position of point to be tested
CrdType | Specifies type of coordinates for Xpos, Ypos. MUST be set to CRD_PIXELS ( = 4 ). Support for other coordinate types is not currently implemented.

Returns

Returns the number of the marker at the specified position, or 0 if no markers lie at the specified point.

See Also

ObjectsHitTest method, ObjectsInRect method, ObjectsOverlappedBy method


ObjectsInRect Method

Description

ObjectsInRect finds all object in current open container that lie in the specified rectangle and returns the number of such objects.

Declaration

Function ObjectsInRect (X1 As Long, Y1 As Long, Ê
Ä X2 As Long, Y2 As Long, Ê
Ä crdType As Integer) As Long

Syntax

res% = MDrawPro. ObjectsInRect ( X1&, Y1&, X2&, Y2&, crdType% )

Parameters

The ObjectsInRect method has the following parameters:

Argument | Description
X1,Y1,X2,Y2 | Coordinates of bounding rectangle
CrdType | Specifies coordinates type and additional flags. This is a BitFlag value formed by OR combination from the following values

Constant | Value | Description
CRD_LOGIC | 0 | Offsets are in global logical coordinates.
CRD_LOGIC_LOCAL | 2 | Offsets are specified in local (container) logical units.
CRD_PIXELS | 4 | Offsets are specified in client pixels.
CRD_SELECT | 4096 | Selects all objects within the specified rectangle
CRD_PARTLY | 8192 | Specifies that any part of an object may be within the specified rectangle, otherwise the whole object must be within the specified boundary

Returns

Returns the number of objects in the current open container which are within the specified boundary.

Note: this method uses the bounding rectangle of objects (for rotated objects, ellipses), NOT their real shapes.

See Also

ObjectsHitTest method, ObjectsOverlappedBy method


ObjectsHitTest Method

Description

This method identifies the object(s) located at the specified coordinates.

Declaration

Function ObjectsHitTest (ByVal posX As Long, ByVal posY As Long, Ê
Ä ByVal Options As Integer) As Integer

Syntax

res% = MDrawPro.ObjectsHitTest posX&, posY&, Options%

Parameters

The ObjectsHitTest has the following parameters:

Argument | Description
posX&, posY& | Coordinates of the test point.
Options% | Additional object criteria to determine a Hit.

Returns

Returns the number of objects, which have been found during the hit test or zero it there are no more objects (the function may be called more than once) at the specified position.

Upon return the Current property is set by MetaDraw to either:

  • OBJ_NULL if no object is found at the specified location.
  • The handle of an object at the specified coordinates, if such an object exists.
  • OBJ_SELECTED if multiple objects have been found and selected (when the FND_SELECT flag was specified in the Options% parameter).

Example

Sub MetaDraw_MouseMove(Button As Integer, Shift As Integer,
                  X As Single, Y As Single)
    Dim lResult&, lX&, lY&
    lX = X / Screen.TwipsPerPixelX
    lY = Y / Screen.TwipsPerPixelY
    With MetaDraw
        lResult = .ObjectsHitTest(lX, lY, 0)
        If lResult = 0 Then
          Label1.Caption = "Mouse is over empty area"
        Else
          Label1.Caption = "Mouse is over object :"
                          &.Current & " With tag = "
                          &.ObjTags ("myname")
        End if
    End With
End Sub

Remarks

MetaDraw uses the Options% parameter to determine a Hit and also to determine which if any objects at the specified location are identified. The Options% parameter can be a combination of the following values:

Constant | Value | Description
OS_CURSOR | &H0001 | Find only objects which have the "Cursor" status flag
OS_HOTSPOT | &H0002 | Find only objects which have the "HotSpot" status flag
OS_CLICK | &H0004 | Find only objects which have the "Click" status flag
OS_WEBURL | &H0008 | Find only objects which have the "WebURL" status flag
OS_SELECTED | &H0010 | Search only among selected objects
OS_VISIBLE | &H0020 | Search only among visible objects
FND_FIRST | &H0000 | Start searching from the first object in container
FND_NEXT | &H0100 | Find next object, whose tag matches specified values. The Current property determines an object from which the search begins
FND_CURRENT | &H0200 | The function attempts to start searching at the object whose handle specified in the Current property. The Current may contain a reserved handle:
 |  | OBJ_SELECTED | look in all selected objects.
 |  | OBJ_CONTAINER | start from the first object in the open container.
 |  | OBJ_CONT_MAIN | Start from main container (used together with FND_RECURSE flag to search for all picture's objects).
FND_INVERT | &H0800 | Invert the condition.
FND_LOGICAL | &H1000 | Use logical coordinates for the posX& and posY& parameters instead of pixels
FND_SELECT | &H4000 | Select all found objects
FND_DESELECT | &H4010 | Deselect all found objects

Normally the function starts searching from the topmost object inside the open container (FND_FIRST value is specified in the Options% parameter). To find the next object at the specified location, include the FND_NEXT flag in the Options% parameter. In this case, the Current property must contain the handle of previous found object.

The function should be called only once when specifying FND_SELECT or FND_DESELECT flags in the Options% parameter. In this case, all objects located at the specified coordinates will be selected (or deselected) and the function returns the number of found objects.

By default, the posX& and posY& parameters are in client pixels. Add the FND_LOGICAL value to the Options% parameter, if values passed as the posX& and posY& parameters are in logical picture coordinates.

See Also

ObjectsInRect method, ObjectsOverlappedBy method, Logical coordinates, Layering order of objects, Current property


ObjectsOverlappedBy Method

Description

The ObjectsOverlappedBy method finds all objects in current open container that are overlapped by the specified object. ( their bounding rectangles overlap)

Declaration

Function ObjectsOverlappedBy (hndObj As Long, nOptions As Integer) As Long

Syntax

res% = MDrawPro.ObjectsOverlappedBy ( objhandle&,Options% )

Parameters

The ObjectsHitTest has the following parameters:

Argument | Description
objHandle | Object to test
nOptions | a bit flag property composed by OR combination from the following table:
 | Constant | Value | Description
 | CRD_BORDER | 16 | Uses objects border. If this flag is set object bounding rectangles will be increased by half of their border width for overlap testing
 | CRD_SELECT | &H1000 | Selects all the found objects.
 | CRD_PARTLY | &H2000 | Any part of the object may be under the object. Otherwise the whole object must be under the specified object (default).
 | CRD_ALLOBJECTS | &H4000 | Scans all the objects in the opened container. Otherwise only objects which are under the specified object will be checked.

Remarks

When set the CRD_BORDER flag instructs MetaDraw to expand the object's bounding rectangle considered in ObjectOverlappedBy by half of the border width. So the chance to get non-overlapping objects will be decreased.

Returns

Returns the number of objects found

See Also

ObjectsHitTest method


ObjHotSpot Property

Description

This property is used to test or set an object's HotSpot as well as Hittable, WebURL statuses.

Usage

[form.]MetaDraw.ObjHotSpot [= BitMaskValue%]

Settings

The ObjHotSpot settings are:

The ObjHotSpot property is set as a BitMask set by OR'g the desired flags.

Setting | Value | Description
OS_CURSOR | 1 | Mouse pointer is set to hand pointer when the mouse is over an object which has this flag set.
OS_HOTSPOT | 2 | The OnHotSpot event is triggered when the mouse is over an object which has this flag set.
OS_CLICK | 4 | The HitObject event is triggered when the mouse is clicked over an object which has this flag set.
OS_WEBURL | 8 | MetaDraw instructs the web browser to jump to the URL specified by the ObjURL property, when the left mouse button is clicked over an object which has this flag set.
OS_DBLCLICK | 1024 | The HitObjectDouble event is triggered when the mouse is Double Clicked over an object which has this flag set. *

Remarks

* HyperGraphic responses to clicking (URL Jumps and Triggering the HitObject or HitObjectDouble event) are enabled only while in EditMode ED_VIEW.

** Hypergraphic responses to mouse movements (Cursor changes and triggering the OnHotSpot event) are enabled only while in EditMode ED_VIEW and while the HotSpots property is set to True.

If the ObjURL property is empty, the OS_WEBURL flag is ignored.

When both OS_WEBURL and OS_CLICK are set and the mouse is clicked over the object, MetaDraw fires the HitObject event first and then calls the web browser to jump to the URL. So, you can change the ObjURL property for the object in the HitObject event before calling the web browser.

The ObjHotSpot settings are saved within the image file when saved as a MetaDraw object (PictureType property = PICTYPE_INTERNAL) or as a metafile (PICTYPE_METAFILE, PICTYPE_ENHMETAFILE).

The Modifications property flag MOD_HITTHROUGH determines how hotspots are recognized for containers and objects within containers. With this bit flag set, MetaDraw reacts to the hotspot status of individual objects under the mouse whether the objects are grouped in a container or not. When the MOD_HITTHROUGH flag bit is clear, the hotspot status of objects within a container group are ignored and MetaDraw will react instead to the hotspot settings of the container object. Objects outside of a container are not affected by this Modifications flag setting.

Data Type

Integer (BitMask)

See also

Changing object's attributes, Using Hot-Spot abilities, OnHotSpot event, ObjURL, ObjStatus, EditMode, and HotSpots properties


ObjLeft Property

Description

See ObjBottom, ObjLeft, ObjRight, ObjTop properties


ObjMove Property

Description

This is an action property, moving MetaDraw's internal object reference pointer and setting Current to the handle of that object.

Usage

[form.]MDraw.ObjMove [= settings%]

Settings

The ObjMove property settings are:

Constant | Value | Description
MOVE_NEXT | 0 | Move to the next object in the list.
MOVE_PREV | 1 | Move to the previous object.
MOVE_FIRST | 2 | Move to the first object in the list of objects.
MOVE_LAST | 3 | Move to the last object.
MOVE_PARENT | 4 | Move to the parent container.
MOVE_CHILD_FIRST | 5 | Move to first child in container's objects list. Prior to this call, Current must reference a valid container.
MOVE_CHILD_LAST | 6 | Move to the last child in container's objects list. Prior to this call, Current must reference a valid container.
MOVE_SEL_NEXT | 7 | Move to the next selected object.
MOVE_SEL_PREV | 8 | Move to the previous selected object.
MOVE_SEL_FIRST | 10 | Move to first selected object.
MOVE_SEL_LAST | 11 | Move to last selected object.
MOVE_CONT_OPENED | 12 | Move to the currently open container.
MOVE_CONT_MAIN | 13 | Move to the handle of the main container.
MOVE_CONT_FIRST | 14 | Move to the first object in the open container.
MOVE_CONT_LAST | 15 | Move to the last object in the open container.
MOVE_OBJ_OPENED | 16 | Move to the currently open object.

Remarks

If there is no object to move to, then Current is set to OBJ_NULL. For example, if Current initially held the handle of the first selected object, setting ObjMove to MOVE_SEL_PREV will reset Current to OBJ_NULL.

Note: The Current property must reference a valid object handle before setting ObjMove to a value from 0 to 8.

Data Type

Integer (Enumerated)

See also

Current property


ObjLinkCount Property

Description

Returns the number of links attached to the graphic object whose handle is specified in the Current property.

Usage

[form.]MDraw.ObjLinkCount

Remarks

The Current property must contain the handle of the graphic object whose links count is retrieved.

There can be several links attached to one object. This property returns the total number of links for the object whose handle is specified in the Current property. If object does not have any links the property returns 0.

Example

With MetaDraw1
    ' Add three selected objects
    .AddObject OT_LINE, 100, 100, 400, 200
    .ObjSelected = True
    .AddObject OT_ELLIPSE, 600, 100, 900, 200
    .ObjSelected = True
    .AddObject OT_RECTANGLE, 400, 600, 600, 800
    .ObjSelected = True
    ' Create links between selected objects
    .CreateLink OBJ_SELECTED, OBJ_SELECTED, 0
    '  move to first selected object
    .ObjMove = MOVE_SEL_FIRST
    '  Check how many links there are
     Debug.Print .ObjLinkCount
         '=>  printed value is 2
         '(In this example there are 2 links for 1st selected object)
End With

Data Type

Integer

See also

ObjLinks property, How to create and manipulate diagram links


ObjLinks Property

Description

Returns the corresponding link attached to the graphic object whose handle is specified in the Current property.

Usage

[form.]MDraw.ObjLinks (<link_index%>)

Remarks

The Current property must contain the handle of the object whose links is retrieved.

The ObjLinks array is zero based – running from 0 to ObjLinkCount-1

The property returns link object handle for the object whose handle is specified in the Current property by the specified index.

Example

' The following code changes endings of all links
' connected to the current object
With MetaDraw1
    CurObj& = .Current  ' Save handle of current object
    NumLinks% = .ObjLinkCount
    While NumLinks% > 0
        NumLinks% = NumLinks% - 1
        .Current = .ObjLinks(NumLinks%)
        .LinkStyle(LNK_START) = LS_FILLARROW
        .Current = CurObj&  ' Restore object's handle
    Wend
End With

Data Type

Long (object handle)

See also

ObjLinkCount property, How to create and manipulate diagram links


ObjNumber Property

Description

This property is used to convert between an object's order number and its handle.

Usage

[form.]MDraw.ObjNumber [= object_number&]

Remarks

This property returns the order number within the container for the object whose handle is specified in the Current property. Object 1 is the first (bottom most) object within the container.

When a value is assigned to this property, MetaDraw sets the Current property to the handle of an object whose ordinal number is equal to the value.

As shown in the example below it is possible to use the ObjNumber property to move through the object list within the current container. This can also be done using the ObjMove property.

Example

   ' Loop through all items inside the open container
   ' beginning at the bottommost object.
   ' List the object numbers, handles and object types
For I = 1 to MDraw.ObjCount(OBJ_CONTAINER)
   MDraw.ObjNumber = I
   Print I, MDraw.Current, MDraw.ObjType
Next I
' The following code does exactly the same as the previous one.
MDraw.ObjMove = MOVE_CONT_FIRST
While MDraw.Current > OBJ_VALID
   Print I, MDraw.Current, MDraw.ObjType
   MDraw.ObjMove = MOVE_NEXT
Wend
Note: This example does NOT loop through objects within a closed Container. The ObjNumber property only enumerates objects directly within the specified open container (a closed container is one solid object). For an example of looping through all objects in an image see "How to Count and Loop Through Objects in an Image"

Data Type

Long

See also

Current property


ObjOpened Property

Description

This property is used to test or toggle an object's "open" status.

Reading the property returns the "opened" status of an object whose handle is specified in the Current property.

Setting this property to TRUE or FALSE opens or closes the object pointed to by the Current property.

Usage

[form.]MDraw.ObjOpened [= {True|False}]

Remarks

Only certain objects can be opened: Containers, Polygons, PolyLines, and Text. An end-user may generally open/close such objects by double clicking on the object while in EditMode ED_SELECT. This action may be prevented with the EditFlags property.

The objects within a container may only be manipulated while the container is Open. In EditMode ED_SELECT, the end-user can then drag or resize those objects. Also you can add objects only into an open container, so you have to open the container where to you want to add objects.

The vertices of an open Polygon or Polyline are shown and may be dragged by the end-user when in EditMode ED_SELECT.

An Open Text object is modified by keyboard action. Of course the MetaDraw control must have the focus in order to receive keyboard access.

When you close an object (set the ObjOpened property to False), MetaDraw automatically opens its parent container. The main container (picture) can not be closed.

Note: The Current property must contain a real object handle (not a reserved handle) when reading/writing the ObjOpened property.

Data Type

Integer (Boolean)

See also

Current property


ObjRight Property

Description

See ObjBottom, ObjLeft, ObjRight, ObjTop properties


ObjResolution Property

Description

ObjResolution is used to control the quality of the resulting object when converting objects to polylines / polygons.

Usage

[form.]MDraw.ObjResolution [= value ]

Remarks

This property defines number of twips per physical inch (unzoomed) used as the basis for coordinate transformation process during object type conversion. The greater the ObjResolution setting, the more accurately the new polygon or polyline will conform to the original shape or text object. The cost is that the higher the setting of ObjResolution, the more memory will be required to represent the object as a polygon/polyline, and also operations on the converted object will be slower.

When value of this property is 1440 we have the same resolution as original picture has. As a result - the polygon / polyline will match the original shape or text at a 1:1 zoom. Setting ObjResolution to a value greater than 1440 provides a reserve of extra accuracy so the converted object will resemble the original shape or text even when zoomed.

Note - .objResolution applies to MetaDraw itself, not to the individual elements in Metadraw.

Default

The default value of 120 is an balance of quality vs performance.

Data Type

Single

See also

ObjType property


ObjRotation Property

Description

Determines the rotation angle for the object.

Usage

[form.]MDraw.ObjRotation [= angle# in degrees]

Remarks

This property sets the rotation angle in degrees for the object. When the specified angle is not in the range from -180° to 180°, MetaDraw will normalize this value so it belongs to such range.

All objects, except Standard Text Objects, are rotated around the center point of its bounded rectangle. The rotation point for Standard Text depends on the Text Alignment.

For text objects which have been associated as LinkLabels on Lines, Links, or Dimension Lines, the OS_LINKANGLE flag in the OBJStatus property determines whether the angle is relative to the horizontal axis, or to the angle of the associated Line, Link or Dimension Line

Data Type

Single

See also

RotateObjects method, FontOrient property


ObjSelected Property

Description

Using for testing or changing the object selection status.

Usage

[form.]MDraw.ObjSelected [= {True|False}]

Remarks

Using this property you can change or test the selection status for the object referenced by the Current property. If the Current property contains the reserved handle OBJ_CONTAINER, assigning True/False to this property sets/drops the selection flag for all objects inside the open container.

The Mouse can also be used to change object selection status (in ED_SELECT edit mode). See the section "Using the mouse to select/unselect objects" in Chapter 2, "Programming with MetaDraw".

You can also set/drop the selection flag using the ObjStatus property.

Example

' The following code removes all containers
' from the open container
MDraw.Current = OBJ_CONTAINER
MDraw.ObjSelected = False    ' Drop selection of all objects
' Select containers
MDraw.ObjMove = OBJ_CONT_FIRST
While MDraw.Current > OBJ_VALID
    If MDraw.ObjType = OT_CONTAINER Then
      MDraw.ObjSelected = True
    End If
    MDraw.ObjMove = MOVE_NEXT
Wend
MDraw.RemoveObject OBJ_SELECTED

Data Type

Integer (Boolean)

See also

Selecting objects, changing object's attributes, Current property


ObjShadow, ObjShadowColor, ObjShadowOfsX,Y Properties

Description

These properties specify the shadow color, style and offsets.

Usage

[form.]MDraw.ObjShadow [= value%]

Values

Constant | Value | Description
SHAD_NONE | 0 | No shadow
SHAD_LIGHT | 1 | Shadows as XOR combination of destination and shadow color
SHAD_NORMAL | 2 | Shadows as solid shadow color

Remarks

The ObjShadow property can be used to present a colored shadow offset for specified objects

ObjShadowOfsX and ObjShadowOfsY specify the offset distance (in logical units) of the shadow from the object.

ObjShadowColor specifies the shadow color

Example

' Add a shadow to all selected objects
MetaDraw.Current = OBJ_SELECTED
MetaDraw.ObjShadow = 1
MetaDraw.ObjShadowOfsX = 50
MetaDraw.ObjShadowOfsY = 50

Data Type

Integer (Boolean)


ObjStatus Property

Description

This property is used to test or toggle an object's status flags.

Usage

[form.]MDraw.ObjStatus [= status_flags%]

Remarks

The value of this property may be set as a combination (OR) of the following flags:

Constant | Value | Description
OS_CURSOR | &H01 | The "Cursor" status flag. The mouse pointer changes its shape to "hand" cursor when over an object assigned this ObjStatus flag. **
OS_HOTSPOT | &H02 | The "HotSpot" status flag. The OnHotSpot event is triggered when the mouse pointer is over an object assigned this ObjStatus flag. **
OS_CLICK | &H04 | The "Click" status flag. Triggers the OnHitObject event in response to a single mouse click upon the object. *
OS_WEBURL | &H08 | The "WebURL" status flag. The object is linked to a URL. A left-mouse click upon the object loads the URL specified in the ObjURL property within the Web browser frame specified by the WebTargetFrame property. *
OS_SELECTED | &H10 | The "Select" status flag. Determines whether the object is selected or not (see the ObjSelected property).
OS_VISIBLE | &H20 | The "Visible" status flag. Determines whether the object is visible in ED_VIEW mode or not (see the ObjVisible property).
OS_LABELANGLE | &H40 | The "Label Angle" status flag. Determines whether rotation angle of a label is set relative to its parent link (or line or dimension line) or to the parent container.
OS_FIXEDBORDER | &H080 | Forces borders of a multi-line text object to remain fixed. Otherwise borders will be automatically adjusted when edited text is too large for the existing border. (If text shrinks, borders are not changed. They are changed only when text caret goes outside the borders during editing)By default this flag is NOT set.
OS_DBLCLICK | &H400 | The HitObjectDouble event is triggered when the mouse is Double Clicked over an object which has this flag set. *

* HyperGraphic responses to clicking within (URL Jumps and Triggering the HitObject or HitObjectDouble event) are enabled only while in EditMode ED_VIEW.

* * Hypergraphic responses to mouse movements (Cursor changes and triggering the OnHotSpot event) are enabled only while in EditMode ED_VIEW and while the HotSpots property is set to True.

The Modifications property flag MOD_HITTHROUGH determines how hotspots are recognized for containers and objects within containers. With this bit flag set, MetaDraw reacts to the hotspot status of individual objects under the mouse whether the objects are grouped in a container or not. When the MOD_HITTHROUGH flag bit is clear, the hotspot status of objects within a container group are ignored and MetaDraw will react instead to the hotspot settings of the container object. Objects outside of a container are not affected by this Modifications flag setting.

Using this property allows changing several objects' status flags at a time. You can equivalently use the ObjHotspot, ObjSelected, ObjVisible properties to change only the corresponding flags.

The Current property determines the set of objects the property acts upon. The Current property can not point to several objects when you read this property.

Example

' The following code makes all selected objects "Invisible"
' and toggles the "Visible", "HotSpot"
' flags for first selected object
MDraw.Current = OBJ_SELECTED
MDraw.ObjVisible = False
MDraw.ObjMove = MOVE_SEL_FIRST
If MDraw.Current > OBJ_VALID Then
    MDraw.ObjStatus = MDraw.ObjStatus Xor (OS_VISIBLE + OS_HOTSPOT)
End If

Data Type

Integer

See also

EditMode, HotSpots, ObjHotspot, ObjSelected, ObjURL properties


ObjTag Property

Description

Specifies string data to be associated with a given object. You can use this property to identify objects, store comments about an object, or to hold a string for use in a HyperGraphic application when the user clicks, etc.

Usage

[form.]MDraw.ObjTag [= tag_string$]

Remarks

By default the ObjTag property is set to an empty string ("") upon creation of an object.

The ObjTag values are saved within the image file when saved in Extended MetaFile format (PICTYPE_METAFILE) or in Internal MetaDraw and MetaFiles formats (PICTYPE_INTERNAL, PICTYPE_METAFILE, PICTYPE_ENHMETAFILE).

This property can also be changed via the ObjTags property, by using an empty tag name. Thus the following two lines perform the same function:

MDraw.ObjTag = "RectString"        ' Set default tag to "RectString"
MDraw.ObjTags("") = "RectString"   ' The same as previous line

Unlike the ObjTags property, the ObjTag property is always of string data type. If a non-string value is assigned to the ObjTags("") property, it will be converted to a string, when you read the ObjTag property.

MDraw.ObjTags("") = 1.52  ' Set default tag to float value 1.52
Name$ = MDraw.ObjTag    ' The Name$ variable contains string "1.52"

Data Type

String

See also

Changing object's attributes, Use Hot-Spot abilities, Current property


ObjTags Property

Description

Specifies user data associated with a given object. Each object can have multiple named tags, each tag value may be of a different data type.

Usage

[form.]MDraw.ObjTags(<tagname$>) [= <value>]

Remarks

By default, there are no tags defined for an object upon its creation. Any data type may be assigned to this property: String, Single, Integer, Data, Currency and other variant types (see Variant type for more information). Even a picture or a control can be assigned to this property.

Upon assignment,

If a tag with the specified name already exists, the associated value is replaced.
If no such tag name currently exists, a new tag is created with specified name and value.

When reading a tag, whose name was not defined, this property returns an empty variant record. When an empty string is specified as name of the tag, this property references to the default tag (the same as ObjTag property).

The ObjTag values are saved within the image file when saved in Internal MetaDraw and MetaFiles formats (PICTYPE_INTERNAL, PICTYPE_METAFILE, PICTYPE_ENHMETAFILE). Only data of standard Variant types (String, Single, Integer, Data, Currency) can be saved with objects. If the ObjTags("…") property contains a Picture or a Control, it will not be saved.

Example

' The Current property must contain the handle of the object
' whose tags we want to change
MDraw.ObjTags("Name") = "Table"
MDraw.ObjTags("Cost") = 129.99
MDraw.ObjTags("") = "A rectangle object"  ' Change the default tag
Name$ = MDraw.ObjTag ' Variable Name$ contains the following
                     ' string: "A rectangle object"

Data Type

Variant

See also

ObjTag property, Changing object's attributes, Current property


ObjTagsCount Property

Description

Each graphic element in MetaDraw can have up to 32,000 associated Object Tags.

The ObjTagsCount property returns the number of defined tags for the object whose handle is specified in the Current property.

Usage

[form.]MDraw.ObjTagsCount [= <num_tags%>]

Remarks

ObjTagsCount returns the number of Object tags that were defined for the specified objects. By default objects do not have any tags and this property returns 0 until tags have been assigned using the ObjTags property.

Setting ObjTagsCount to 0 deletes all ObjectTags associated with the current element.

Setting ObjTagsCount to a value less than the current number of ObjTags for a specified item removes the "extra" tags.

Setting ObjTagsCount to a value greater than the number of tags defined for the element will have no result.

Example

'  Create a Rectangle Object
Mdraw.AddObject OT_Rectangle, X1, Y1, X2, Y2
' .Current must point to the object whose tags we want to set
'  After AddObject, .Current points to the most recently added object
MDraw.ObjTags("Name") = = "Desk"
MDraw.ObjTags("Cost") = 129.99
MDraw.ObjTag = "fred's desk"   ' ObjTag is a default tag with no name
num_tags% = MDraw.ObjTagCount      ' num_tags% are equal 3 now
MDraw.ObjTagCount = 0         ' Deletes all tags

Data Type

Integer

See also

ObjTags property, Changing object's attributes


ObjTagsName Property

Description

Each graphic element in MetaDraw can have up to 32,000 associated Object Tags. Each tag has a name which is assigned when the tag is created.

The ObjTagsName property is an array property which holds the names of all Object Tags associated with an element whose handle is specified in the Current property.

Usage

[form.]MDraw.ObjTagsName (<tag_index%>) [= <string$>]

Remarks

The ObjTagsName array is zero-based – the first element in the array is ObjTagsName(0).

It is possible to change a tag's name by assigning a new value to this property.

Note: Tag names are case sensitive, so "Tag" and "TAG" are different tag names.

Example

 This code converts all tag names to UpperCase strings
' The Current property must contain the handle of the object
' whose tag names we want to change
For I% = 1 To MDraw.ObjTagsCount
    MDraw.ObjTagsName(I%-1) = UCase(MDraw.ObjTagsName(I%-1))
Next I%

Data Type

String

See also

ObjTags property, ObjTagsCount property,


ObjTagsValue Property

Description

Each graphic element in MetaDraw can have up to 32,000 associated Object Tags.

The ObjTagsValue property is an array property which holds the values of all Object Tags associated with an element whose handle is specified in the Current property.

Usage

[form.]MDraw.ObjTagsValue (<tag_index%>) [= <variant>]

Remarks

The Current property must contain the handle of the object whose tags are changed.

The ObjTagsValue array is zero-based – the first element in the array is ObjTagsValue(0).

Example

' The Current property must contain the handle of the object
' whose tags we want to change
MDraw.ObjTags("Name") = "Table"
MDraw.ObjTags("Cost") = 129.99
Print MDraw.ObjTagsValue(0), MDraw.ObjTagsValue(1)
'    >> "Table   129.99" will be printed
MDraw.ObjTagsValue(1) = 225.95
Print MDraw.ObjTagsValue (0), MDraw.ObjTagsValue (1)
'    >> "Table   225.95" will be printed

Data Type

Variant

See also

ObjTags, ObjTagsName, ObjTagsCount properties


ObjTop Property

Description

See ObjBottom, ObjLeft, ObjRight, ObjTop properties


ObjType Property

Description

Returns type of the object or group of the objects.
Setting this property will convert an object from one type to another.

Usage

object_type = [form.]MDraw.ObjType

Settings

The ObjType property settings are:

Constant | Value | Description
OT_CONTAINER | 0 | Container (group of objects) *
OT_LINE | 1 | Line
OT_RECTANGLE | 2 | Rectangle
OT_ROUNDRECT | 3 | Rounded rectangle
OT_ELLIPSE | 4 | Ellipse (circle)
OT_ARC | 5 | Arc
OT_PIE | 6 | Pie (sector)
OT_CHORD | 7 | Chord
OT_POLYLINE | 8 | Polyline
OT_POLYGON | 9 | Polygon
OT_TEXT | 10 | Text
OT_BITMAP | 11 | Bitmap *
OT_PICTURE | 13 | Image *
OT_BEZIER | 14 | Bezier curve
OT_POLYPOLYGON | 15 | PolyPolygons *
OT_SOLIDPICTURE | 16 | Object which presents a metafile *loaded with PICOPT_SOLIDMETAFILE or PICOPT_SOLIDENHMETAFILE flags of PictureOptions property *
OT_FLOODFILL | 19 | Floodfill *
OT_LINK | 21 | Link
OT_DIMLINE | 22 | Dimension line
OT_POLYLINK | 21 | PolyLink *

* object types marked by asterisk may not be converted to or from other types

Remarks

Reading this property identifies the type of object(s) pointed to by the Current property. If Current specifies more then one object (a group of selected objects) and these objects are not the same type generates an error.

When converting objects ( other than Text objects) to a Polyline (Polygon), the ObjResolution property determines how many points are used for the resulting polyline.

Note that Object Type conversion may not be reversible. It is possible to convert an Arc to a polyline, but it is not possible to convert a polyline back to an Arc.

Data Type

Integer

See also

ObjResolution property


ObjURL Property

Description

Specifies an associated internet URL for the object specified by the Current property.

Usage

[form.]MDraw.ObjURL [= url$]

Remarks

MetaDraw executes a "URL Jump" in response to left-mouse clicks on URL enabled objects (the object has the OS_WEBURL flag set in the ObjStatus (ObjHotSpot) property), and when EditMode = ED_VIEW.

When executing a URL Jump, the web browser will be launched (if not already opened) and passed the value of the ObjURL property as a Web Address. If a relative URL is specified in this property, the value of the WebURLBase property is used to construct the full URL. The WebTargetFrame property determines the frame in which the referenced resource will be loaded.

The Modifications property flag MOD_HITTHROUGH determines how hotspots ( including ObjURL settings) are recognized for containers and objects within containers. With this bit flag set, MetaDraw reacts to the hotspot status of individual objects under the mouse whether the objects are grouped in a container or not. When the MOD_HITTHROUGH flag bit is clear, the hotspot status of objects within a container group are ignored and MetaDraw will react instead to the hotspot settings of the container object. Objects outside of a container are not affected by this Modifications flag setting.

Note: The OS_HOTSPOT, OS_CLICK, and OS_WEBURL flags are automatically set when a URL is assigned to the object.

Data Type

String

See also

Working with the Internet, WebURLBase, WebTargetFrame, ObjStatus properties


ObjVisible Property

Description

This property is used to test or toggle the object's visible status, hiding the object from display when in View mode.

Usage

[form.]MDraw.ObjVisible [= {True|False}]

Remarks

Use this object's flag to hide some objects (e.g. hotspot areas). When this flag is False the object will not be shown, but all events will occur.

This flag affects the display only when the EditMode property is ED_VIEW (0) and the ShowInvisible property is False. Otherwise, all objects are always visible, in spite of the 'ObjVisible' flag.

Note: No objects within a container for which the ObjVisible property is False will be displayed, even if objects inside it have their Visible flag set to True.

Data Type

Integer (Boolean)

See also

Changing object's attributes, Use Hot-Spot abilities, Current property


OLECompleteDrag Event

Description

This event occurs when MetaDraw is dropped onto a target component, informing MetaDraw that a drag action was either performed or canceled.

Syntax

Sub MetaDraw_OLECompleteDrag (ByRef Effect As Long)

Parameters

Parameters of the OLECompleteDrag event are:

Parameter | Description
Effect& | A long integer set by the source object identifying the action that has been performed, thus allowing the source to take appropriate action if the component was moved (such as the source deleting data if it is moved from one component to another). The possible values are listed in Settings.The settings for Action& are:
 | Constant | Value | Description
 | vbDropEffectNone | 0 | Drop target cannot accept the data, or the drop operation was canceled.
 | vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
 | vbDropEffectMove | 2 | Drop results in data being moved from the drag source to the drop source. he drag source should remove the data from itself after the move.

Remarks

The OLECompleteDrag event is the final event to be called in an OLE drag/drop operation. This event informs MetaDraw of the action that was performed when the object was dropped onto the target component. The target sets this value through the effect parameter of the OLEDragDrop event. Based on this, MetaDraw can then determine the appropriate action it needs to take. For example, if the object was moved into the target (vbDropEffectMove), the source needs to delete the object from itself after the move.

If OLEDragMode is set to OLEDragAutomatic, then MetaDraw handles the default behavior (e.g. if Effect& is vbDropEffectMove MetaDraw will delete copied picture/objects). The event still occurs, however, allowing the user to add to or change the behavior (it is possible to change value Effect& parameter to vbDropEffectNone to avoid picture deletion in moving operation).

See also

OLE Drag & Drop techniques, OLEDrag method , OLEStartDrag event


OLEDrag Method

Description

This method causes MetaDraw to initiate an OLE drag/drop operation..

Syntax

Sub MetaDraw_OLEDrag ()

Remarks

When the OLEDrag method is called, MetaDraw's OLEStartDrag event occurs, allowing it to supply data to a target component. By default when OLE drag operation begins MetaDraw sets data object formats to all supported MetaDraw formats: .BMP, .WMF, .EMF, .MDP, that can be changed later in the OLEStartDrag event.

See also

OLE Drag & Drop techniques, OLEDragMode property, OLEStartDrag event


OLEDragDrop Event

Description

This event occurs when a source component is dropped onto MetaDraw when the source component determines that a drop can occur.

Syntax

Sub MetaDraw_OLEDragDrop (Data As MetaDrawLib.MDDataObject, Ê
Ä ByRef Effect As Long, Ê
Ä ByVal Button As Integer, Shift As Integer, Ê
Ä ByVal X As Single, ByVal Y As Single)

Parameters

Parameters of the OLEDragDrop event are:

Parameter | Description
data | A MDDataObject object containing formats that the source will provide and, in addition, possibly the data for those formats. If no data is contained in the MDDataObject, it is provided when the control calls the GetData method. The SetData and Clear methods cannot be used here.
Effect& | A long integer set by MetaDraw target identifying the action that has been performed (if any), thus allowing the source to take appropriate action if the component was moved (such as the source deleting the data). The possible values are listed below:
 | Constant | Value | Description
 | vbDropEffectNone | 0 | Drop target cannot accept the data.
 | vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
 | vbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
 | vbDropEffectScroll | 0x80000000 | A mask to indicate that the drop target window has scrolled/would scroll.
Button% | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The left button is bit 0, the right button is bit 1, and the middle button is bit 2. These bits correspond to the values 1, 2, and 4, respectively. It indicates the state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are depressed.
Shift% | An integer which acts as a bit field corresponding to the state of the shift, ctrl, and alt keys when they are depressed. The shift key is bit 0, the ctrl key is bit 1, and the alt key is bit 2. These bits correspond to the values 1, 2, and 4, respectively. The shift parameter indicates the state of these keys; some, all, or none of the bits can be set, indicating that some, all, or none of the keys are depressed. For example, if both the ctrl and alt keys are depressed, the value of Shift% would be 6.
X, Y | A number that specifies the current horizontal (X) and vertical (Y) position of the mouse pointer within MetaDraw. The X and Y values are always expressed in pixels.

Remarks

This event occurs only if OLEDropMode is set to 1 (OLEDropManual). In Automatic mode (OLEDropMode is OLEDropAutomatic) MetaDraw automatically inserts the appropriate picture at the drop position.

See also

OLE Drag & Drop techniques, OLEDropMode property, OLEDragOver event


OLEDragMode Property

Description

This property determines who handles an OLE drag operation: the component or the programmer.

Usage

[form.]MetaDraw.OLEDragMode [= drag_mode%]

Settings

The OLEDragMode property settings are:

Constant | Value | Description
OLEDragManual | 0 | (default). The programmer handles all OLE drag/drop operations.
OLEDragAutomatic | 1 | The component handles all OLE drag/drop operations automatically.

Remarks

When OLEDragMode is set to OLEDragManual, the programmer must call the OLEDrag method to start dragging, which then triggers the OLEStartDrag event.

When OLEDragMode is set to OLEDragAutomatic, MetaDraw fills the MDDataObject object with the set of pictures generated according to current edit mode and selected objects and sets the effects parameter before initiating the OLEStartDrag event (as well as the OLESetData and other source-level OLE drag/drop events) when the user attempts to drag out of the control. This gives the programmer control over the drag/drop operation and allows to intercede by adding other formats, or by overriding or disabling the automatic data and formats using the Clear or SetData methods. By default MetaDraw fills the MDDataObject with all supported formats: .BMP, .WMF, .EMF, .MDP (see OLEStartDrag for more information).

If there is and no data loaded (or it is cleared) in the OLEStartDrag event, or AfterEffects% is set to 0, then the OLE drag/drop operation does not occur.

In automatic drag mode OLE drag operation starts only when the left mouse button is pressed and the mouse pointer is moved on several pixels.

Note: If the DragMode property of a control is set to Automatic, the setting of OLEDragMode is ignored, because regular Visual Basic drag and drop events take precedence.

Data Type

Integer.

See also

OLE Drag & Drop techniques, OLEStartDrag, OLESetData events


OLEDragOver Event

Description

This event occurs when one component is dragged over another.

Syntax

Sub MetaDraw_OLEDragOver (Data As MetaDrawLib.MDDataObject, Ê
Ä ByRef Effect As Long, Ê
Ä ByVal Button As Integer, Shift As Integer, Ê
Ä ByVal X As Single, ByVal Y As Single, Ê
Ä ByVal State As Integer)

Parameters

Parameters of the OLEDragOver event are:

Parameter | Description
data | A DataObject object containing formats that the source will provide and, in addition, possibly the data for those formats. If no data is contained in the DataObject, it is provided when the control calls the GetData method. The SetData and Clear methods cannot be used here.
Effect& | A long integer initially set by the source object identifying all effects it supports. This parameter must be correctly set by the target component during this event. The value of effect is determined by logically Or'ing together all active effects. The target component should check these effects and other parameters to determine which actions are appropriate for it, and then set this parameter to one of the allowable effects (as specified by the source) to specify which actions will be performed if the user drops the selection on the component. The possible values are listed below:
 | Constant |  | Value |  | Description
 | vbDropEffectNone |  | 0 |  | Drop target cannot accept the data.
 | vbDropEffectCopy |  | 1 |  | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
 | vbDropEffectMove |  | 2 |  | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
 | vbDropEffectScroll |  | 0x80000000 |  | Scrolling is occurring or about to occur in the target component. This value is used in conjunction with the other values.
Button% | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The left button is bit 0, the right button is bit 1, and the middle button is bit 2. These bits correspond to the values 1, 2, and 4, respectively. It indicates the state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are depressed.
Shift% | An integer which acts as a bit field corresponding to the state of the shift, ctrl, and alt keys when they are depressed. The shift key is bit 0, the ctrl key is bit 1, and the alt key is bit 2. These bits correspond to the values 1, 2, and 4, respectively. The shift parameter indicates the state of these keys; some, all, or none of the bits can be set, indicating that some, all, or none of the keys are depressed. For example, if both the ctrl and alt keys are depressed, the value of Shift% would be 6.
X, Y | A number that specifies the current horizontal (X) and vertical (Y) position of the mouse pointer within MetaDraw. The X and Y values are always expressed in pixels.
State% | An integer that corresponds to the transition state of the control being dragged in relation to MetaDraw. The possible values are listed below:
 | Constant | Value |  | Description
 | vbEnter | 0 |  | Source component is being dragged within the range of MetaDraw.
 | vbLeave | 1 |  | Source component is being dragged out of the range of MetaDraw.
 | vbOver | 2 |  | Source component has moved from one position in MetaDraw to another.

Remarks

Note: | This event occurs only if OLEDropMode is set to 1 (OLEDropManual).
Note: | If the State% parameter is vbLeave, indicating that the mouse pointer has left the target, then the X and Y parameters will contain zeros.

See also

OLE Drag & Drop techniques, OLEDropMode property, OLEDragDrop event


OLEDropMode Property

Description

This property returns or sets how MetaDraw handles OLE drop operations.

Usage

[form.]MetaDraw.OLEDropMode [= drop_mode%]

Settings

The OLEDropMode property can be set an enumerated integer which specifies the method which a component handles OLE drag/drop operations, as described below:

Constant | Value | Description
OLEDropNone | 0 | The target component does not accept OLE drops and displays the No Drop cursor.
OLEDropManual | 1 | MetaDraw triggers the OLE drop events, allowing the programmer to handle the OLE drop operation in code.
OLEDropAutomatic | 2 | MetaDraw automatically accepts OLE drops if the DataObject object contains data in a format it recognizes.

Remarks

When OLEDropMode is set to OLEDropAutomatic, MetaDraw process drop operations automatically. No mouse or OLE drag/drop events on MetaDraw will occur in that case. When OLE drop action is performed on target MetaDraw, it scans DataObject on one of MetaDraw acceptable format according to the following priorities: MetaDraw internal format, Enhanced metafile, Windows metafile, DIB, Bitmap, Text. If MDDataObject contains any acceptable picture MetaDraw insert it at the position specified by the mouse coordinates. Otherwise, D&D operation is ignored.

If the OLEDropMode property is set to OLEDropManual, the programmer should handle the OLEDragDrop event to process the drop action. If the OLEDragDrop event is not handled no action will be performed.

Data Type

Integer

See also

OLE Drag & Drop techniques, OLEStartDrag, OLESetData events


OLEGiveFeedback Event

Description

This event occurs after every OLEDragOver event. OLEGiveFeedback allows the source MetaDraw to provide visual feedback to the user, such as changing the mouse cursor to indicate what will happen if the user drops the object, or provide visual feedback on the selection (in MetaDraw) to indicate what will happen.

Syntax

Sub MetaDraw_OLEGiveFeedback (ByRef Effect As Long, Ê
Ä ByVal DefaultCursors As Boolean)

Parameters

Parameters of the OLEGiveFeedback event are:

Parameter | Description
Effect& | A long integer set by the target component in the OLEDragOver event specifying the action to be performed if the user drops the selection on it. This allows MetaDraw to take the appropriate action (such as giving visual feedback). The possible values are listed below:
 | Constant | Value | Description
 | vbDropEffectNone | 0 | Drop target cannot accept the data.
 | vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
 | vbDropEffectMove | 2 | Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
 | vbDropEffectScroll | 0x80000000 | Scrolling is occurring or about to occur in the target component. This value is used in conjunction with the other values.
DefaultCursors | A Boolean value which determines whether MetaDraw uses the default mouse cursor provided by the component, or uses a user-defined mouse cursor. True (default) = use default mouse cursor. False do not use default cursor. Mouse cursor must be set with the MousePointer property of the Screen object.

Remarks

If there is no code in the OLEGiveFeedback event, or if the DefaultCursors parameter is set to True, then MetaDraw automatically sets the mouse cursor to the default cursor provided by the component.

See also

OLE Drag & Drop techniques, OLEDrag method, OLEDragDrop event


OLESetData Event

Description

This event occurs on a source MetaDraw when a target component performs the GetData method on the source's MDDataObject object, but if the data for the specified format has not yet been loaded.

Syntax

Sub MDraw_OLESetData (Data As MetaDrawLib.MDDataObject, Ê
Ä ByVal dataformat As Long)

Parameters

Parameters of the OLESetData event are:

Parameter | Description
Data | A MDDataObject object in which to place the requested data. MetaDraw calls the SetData method to load the requested format.
dataformat& | An integer specifying the format of the data that the target component is requesting. MetaDraw uses this value to determine what to load into the MDDataObject object.

Remarks

In certain cases, it is better to defer loading data into the MDDataObject object of MetaDraw to save time, especially because MetaDraw supports many different formats each of them may request large amount of memory. To avoid of loading of all supported formats into the MDDataObject object, in the OLEStartDrag event MetaDraw can only specify supported formats, but do not load data for each format. In that case, this event allows MetaDraw to respond to only one request for a given format of data.

When a target componet calls the GetData method of MDDataObject object and it does not contain data for the requested format, MetaDraw fires the OLESetData event to allow the user to fill data itself. Otherwise (if data is already prepared) MetaDraw immediately returns the corresponding data.

After the OLESetData event has been called, MetaDraw checks if data for the requested format has been created by the user. If the OLESetData event was not handled or user did not provide data for the requested format (independent of the OLEDragMode property setting), MetaDraw loads data into data object by itself according to the following rule:

  • If the EditMode property is ED_VIEW then MetaDraw exports its main picture to the requested format and load it into the data object.
  • If the EditMode property is ED_EDIT, then the resulted picture will be created from selected objects only.
Note: If the GetData method of MDDataObject object is called inside the OLESetData event MetaDraw returns data for the requested format (existent or prepared by MetaDraw) without calling the OLESetData event again.

See also

OLE Drag & Drop techniques, OLEDrag method, OLEStartDrag event


OLEStartDrag Event

Description

This event occurs when MetaDraw's OLEDrag method is performed, or when MetaDraw initiates an OLE drag operation when the OLEDragMode property is set to OLEDragAutomatic.

This event specifies the data formats and drop effects that MetaDraw supports. It can also be used to insert new data formats into the MDDataObject object.

Syntax

Sub MDraw_OLEStartDrag (Data As MetaDrawLib.MDDataObject, Ê
Ä ByRef AllowedEffects& As Long)

Parameters

Parameters of the OLEStartDrag event are:

Parameter | Description
Data | A MDDataObject object containing formats that MetaDraw will provide and, optionally, the data for those formats. If no data is contained in the MDDataObject, it is provided when the target control calls the GetData method, and you should provide the values for the data parameter in the OLESetData event.
AllowedEffects& | A long integer containing the effects that MetaDraw supports. The settings for AllowedEffects& are:
 | Constant | Value | Description
 | vbDropEffectNone | 0 | Drop target cannot accept the data.
 | vbDropEffectCopy | 1 | Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation.
 | vbDropEffectMove | 2 | Drop results in data being moved from MetaDraw to drop source. MetaDraw will remove the data from itself after the move.

Remarks

By default when OLE drag operation begins (either by calling the OLEDrag method or when automatic mode is activated) MetaDraw sets data object formats to all supported MetaDraw formats: .BMP, .WMF, .EMF, .MDP. data object does not contain any real data, it only provides supported formats, data with the requested format will be filled when a target component performs the GetData method. MetaDraw supports both copy and move effects so by default AllowedEffects& is set to 3.

In this event the programmer can change default data formats and allowed effects as well as assign real data in any formats to the data object.

The OLEStartDrag event also occurs if MetaDraw's OLEDragMode property is set to OLEDragAutomatic. This allows to add formats and data to the MDDataObject object after MetaDraw has done so. Programmers can also override the default behavior of MetaDraw by clearing the MDDataObject object (using the Clear method) and then adding their data and/or formats.

Programmers may want to defer placing data into the MDDataObject object until the target component requests it. This allows MetaDraw to save time by not loading multiple data formats. When the target performs the GetData method on the MDDataObject, MetaDraw's OLESetData event will occur if the requested data is not contained in the MDDataObject. At this point, the data can be loaded into the MDDataObject, which will in turn provide the data to the target. If the OLESetData event is not handled MetaDraw fills data (picture) with the requested format itself.

Picture that will be placed by MetaDraw into data object depends on the current edit mode. If the EditMode property is equal to ED_VIEW MetaDraw creates pictures from the entire MetaDraw picture. In editing mode (ED_EDIT) MetaDraw creates pictures from the selected objects. If there is no objects selected drag/drop operation will not be started.

If the user does not load any formats into the MDDataObject, clear all defined formats or set AllowedEffects& to zero, then the drag/drop operation is canceled.

See also

OLE Drag & Drop techniques, OLEDrag method, OLESetData event


OnHotSpot Event

Description

This event occurs when the mouse is moving over an object which has the "HotSpot" flag set.

Syntax

Sub MDrawPro_OnHotSpot ([Index As Integer,] Ê
Ä ByVal X As Long, ByVal Y As Long, State As Integer)

Parameters

Parameters | Description
X, Y | The current mouse pointer coordinates in the MetaDraw client window (in pixels). The coordinates conversion properties (ClientToLogicX/Y, LogicToClientX,Y ) can be used to convert pixel coordinates into picture logical coordinates.
State | It can be set by MetaDraw to 0, 1, or 2 indicate what triggered the event or it may be set within the event routine to –1 to tell MetaDraw not to change the mouse cursor.

Constant | Value | Description
EHS_USERCURSOR | -1 | Don't change cursor.
EHS_ENTER | 0 | Mouse pointer is moved upon object in first time.
EHS_LEAVE | 1 | Mouse pointer leaves 'hotspot' object.
EHS_OVER | 2 | Mouse is moving over the object.

Remarks

This event occurs only within EditMode = ED_VIEW, and only if the HotSpots property is True and it was not masked in the EventMask property.

When the OnHotSpot event is triggered, the Current property is temporarily reset by MetaDraw to point to the topmost object in the object stacking order which has an ObjHotSpot flag and which lies under the mouse pointer. The value of Current after OnHotSpot is returned to it's prior value after the event is processed.

Setting the State parameter to EHS_USERCURSOR within this event instructs MetaDraw to NOT change the cursor shape to "hand" when the mouse is over the "hotspot" object. This may be helpful when you want to set your own cursor for "Hotspot" objects.

As an alternative to the OnHotSpot event, you can use the ObjectsHitTest method inside the MouseUp event in any edit mode to get the handle of the object under the mouse cursor.

The Modifications property flag MOD_HITTHROUGH determines how hotspots are recognized for containers and objects within containers. With this bit flag set, MetaDraw reacts to the hotspot status of individual objects under the mouse whether the objects are grouped in a container or not. When the MOD_HITTHROUGH flag bit is clear, the hotspot status of objects within a container group are ignored and MetaDraw will react instead to the hotspot settings of the container object. Objects outside of a container are not affected by this Modifications flag setting.

Note: This event will not occur if the mouse pointer leaves the MetaDraw box window, or is moves over a window which lies above the MetaDraw box. Be careful, you can receive OnHotSpot event with State parameter as STATE_ENTER and then never receive this event when State is STATE_LEAVE (in the case, for example, when the mouse pointer leaves the MetaDraw box and a new picture was assigned at the time).

Example

' Change the cursor for the "hotspot" object
Sub MDrawPro_OnHotSpot (ByVal X As Long, ByVal Y As Long, _
                  State As Integer)
   Select Case State
   Case EHS_ENTER
      MDrawPro.MouseCursor = MDrawPro.ObjTags("Cursor")
      MDrawPro.MousePointer = MPTR_USER
      State = EHS_USERCURSOR
   Case EHS_LEAVE
      MDrawPro.MousePointer = MPTR_DEFAULT
   End Select
End Sub

See also

Use Hot-Spot abilities, Current property, EventMask, HotSpots, ObjHotSpot properties, ObjectsHitTest method


OpenDraw Property

Description

This property determines which part of the picture will be re-painted. It can be either the entire picture or only the open container.

Usage

[form.]MDraw.OpenDraw [= settings%]

Settings

The OpenDraw property settings are:

Constant | Value | Description
OPDR_FULL | 0 | Paint the whole picture.
OPDR_CONTAINER | 1 | Paint only the open container. Objects outside the open container will not be displayed.
OPDR_HATCHED | 2 | objects that lie outside the open container will be displayed as hatched outlines/boundaries.

Remarks

When the container is opened (by mouse double-click or by assigning True to the ObjOpened property) the picture will be automatically repainted.

Data Type

Integer (Enumerated)

See Also

Repaint property


OrigHeight, OrigWidth Properties

Description

The OrigWidth and OrigHeight properties are the original height and width of the picture in units specified by the ScaleUnits property or the parent control scaling mode (by default is in twips).

Usage

Width = [form].MDraw.OrigWidth

Height = [form].MDraw.OrigHeight

Remarks

Every picture created or loaded into a MetaDraw control has a certain height and width as its intrinsic attributes. They were defined when the picture was first created and cannot be changed afterwards. The original size is calculated depending upon the picture type. For a bitmap or an icon, it is produced from the bitmap's pixel dimensions (or icon's standard dimensions), using the current display resolution. For a metafile, the original size is stored in a header which VB provides for every metafile loaded.

The OrigWidth/OrigHeight properties can be changed using VB code only when there is no picture loaded in the control. (Set PicWidth or PicHeight to 0 in order to re-initialize the picture before setting OrigHeight and OrigWidth.)

Set these properties to determine the actual dimensions of the picture being created, then create the image by assigning an empty image to the Picture property.

' clear the MetaDraw picture
MetaDraw.PicWidth = 0
'Set the desired original size (5 inches)
MetaDraw.OrigWidth = 5760
MetaDraw.OrigHeight = 5760
'Initialize with empty picture
MetaDraw.Picture = LoadPicture()
' Now use AddObject Method
' to create the desired image, or allow end-user to draw

Note that loading an image into the Picture property of MetaDraw resets these properties automatically, to reflect the original picture size.

When a picture is already loaded, the typical use of OrigWidth and OrigHeight properties is as a reference to the unzoomed size of the picture, by which to set a zoomed visible display. For example, the following code displays the picture 200% enlarged relative to its original size:

MetaDraw.ZoomFactor = 2

The AutoScale property may also be used to display the picture at its original size.

Data Type

Long

See Also

Logical coordinates, AutoScale property, ZoomFactor, PicXSize and PicYSize properties, ScaleUnits property


Parent Property

Description

This standard property specifies a form in which the control is located.

Usage

[form].MDraw.Parent

Data Type

Form

See Also

Parent property in the Microsoft Visual Basic Language Reference


PasteFromClipboard Method

Description

Inserts a picture from the clipboard into MetaDraw. This method may be used to replace the entire image or to merge in a picture pasted from the clipboard.

Declaration

Function PasteFromClipboard (ByVal ClbMask As Integer, Ê
Ä ByVal PicDst As Integer) As Integer

Syntax

result% = PasteFromClipboard (ClbMsk%, PicDst%)

Parameters

The PasteFromClipboard method uses these arguments:

Argument | Description
ClbMask% | Determines which formats can be copied from the clipboard. This is a bitwise mask composed from the following values:
 | Constant | Value |  | Description
 | CLB_METADRAW | 0x01 |  | MetaDraw internal format
 | CLB_BITMAP | 0x02 |  | Bitmap
 | CLB_DIB | 0x04 |  | DIB
 | CLB_PALETTE | 0x08 |  | Palette
 | CLB_METAFILE | 0x10 |  | Metafile
 | CLB_ENHMETAFILE | 0x20 |  | Enhanced metafile
 | CLB_TIFF | 0x40 |  | TIFF
picDst% | Determines destination of the paste operation. The following values are valid:
 | Constant |  | Value |  | Description
 | PIC_PICTURE |  | 0 |  | Paste to the main picture - Replace main picture from the Clipboard.
 | PIC_PICTUREIMAGE |  | 1 |  | Paste to Picture Image.
 | PIC_PICTURECLIP |  | 2 |  | Paste to PictureClip property - Acts to MERGE pasted image into overall image.
 | PIC_CHECKCLBFORMATS |  | 3 |  | Checks whether picture in clipboard has the same format as specified in ClbMask% parameter.

Returns

0 - none of the requested formats are available in the clipboard

> 0 - indicates the format of the image copied from the clipboard,
- OR - ( If PicDst% = PIC_CHECKCLBFORMATS ) provides a bit mask identifying which image formats are currently held in the clipboard.

Remarks

If there are several available data formats in the clipboard, MetaDraw chooses one of them according to the following priority ranking:

MetaDraw Internal format,
Enhanced metafile,
Windows metafile,
DIB,
Bitmap.

If the PIC_PICTURECLIP value is specified as destination, MetaDraw inserts the corresponding picture from the clipboard into main picture as a single object. The Current property will contain the handle of inserted object.

Example

' The following line inserts an enhanced metafile from the clipboard
' into the main MetaDraw picture
MDraw.PasteFromClipboard CLB_ENHMETAFILE, PIC_PICTURECLIP
' The following line copies either a metafile or bitmap
' from the clipboard to the temporary image
MDraw.PasteFromClipboard CLB_METAFILE + CLB_DIB, PIC_PICTUREIMAGE
' The PIC_CHECKCLBFORMATS flag may be used to check
' if some specific image format exists in the clipboard
IsBMPFormatAvailable =
       ( CLB_BITMAP = MetaDraw1.PasteFromClipboard(
                  CLB_BITMAP, PIC_CHECKCLBFORMATS) )

See Also

CopyToClipboard method, PictureClip property


PicBackColor, PicBorderColor Properties

Description

The PicBackColor property specifies the color to be used as a background inside the picture rectangle.

The PicBorderColor property specifies the color to be used as a background outside the picture bounds or when no picture is present.

Usage

[form].MDraw.PicBackColor [= color_expression]

[form].MDraw.PicBorderColor [= color_expression]

Remarks

PicBackColor and PicBorderColor are used as shown on the following picture:

PicBorderColor also determines the color filling the MetaDraw's client area when no picture is loaded.

PicBackColor also specifies the transparent color in the conversion of the picture to ICON. .

The PicBackColor, PicBorderColor properties are also used to specified the gradient colors when GradientStyle is not 0.

Example:

' Set horizontal gradient from blue color to green
MDraw.GradientStyle = GRS_LEFTTORIGHT
MDraw.PicBackColor = RGB(0, 0, 255)
MDraw.PicBorderColor = RGB(0, 255, 0)

Data Type

Long (Color)

See Also

Displaying and Scrolling the picture


PicLeft, PicTop, PicWidth, PicHeight Properties

Description

These properties define a logical coordinate system - used for setting and manipulating object boundaries within the overall image. These coordinates are independent of the physical dimensions of the image.

Usage

[form].MDraw.PicLeft [= some_X]

[form].MDraw.PicTop [= some_Y]

[form].MDraw.PicWidth [= some_W]

[form].MDraw.PicHeight [=some_H]

Remarks

Setting PicWidth or PicHeight to Zero destroys the current picture, (empties the MetaDraw control). The actual desired values of PicWidth and PicHeight should then be set. This should be done before attempting to set PicLeft, PicTop, OrigHeight and OrigWidth for a new image.

When you assign a new picture to the MetaDraw control, the scaling properties are automatically changed to reflect the logical units for the new picture:

  • If the picture is a bitmap or an icon, the PicLeft and PicTop properties become zero, and the PicWidth and PicHeight get their values from the actual bitmap dimensions (in pixels).
  • If the picture is a metafile, the MetaDRAW searches through the metafile for the SetWindowOrg() and SetWindowExt() records and uses their parameters to set logical units.
  • If there are no SetWindowOrg()/SetWindowExt() records near the beginning of the metafile, then the PicLeft and PicTop properties are set to lowest values used in the metafile's records, and the PicWidth/PicHeight are set to the difference between highest and lowest values.
  • The original size (OrigWidth/OrigHeight properties) is calculated differently, depending upon the picture type. For a bitmap or an icon, it is produced from the bitmaps pixel dimensions (or icons standard dimensions), using the current display resolution. For a metafile, the original size is stored in a header which VB provides for every metafile loaded.
  • Offsets of the picture visible rectangle (PicXOfs, PicYOfs properties) are assigned a value of zero (picture will be displayed from left-top corner of the MetaDraw control box). Size of the visible picture (PicXSize, PicYSize properties) is assigned the original picture size.

For best presentation it is important to set PicWidth and PicHeight to maintain equal coordinate resolution in the X and Y directions – the ratios PicWidth/OrigWidth and PicHeight/OrigHeight should be equal.

Note: These properties are Long , not scaleable Single (floating point) values as in other coordinate/size properties. They don't depend upon the parent control's scaling mode. They determine only resolution of the picture that is loaded in the MetaDraw control box.

Note: Note that the standard for Windows MetaFile Format(WMF) only supports resolution settings up to 32,767 – higher values should not be used for PicWidth and PicHeight if the image is to be exported to WMF format.

Data Type

Long

Defaults

The default coordinate system runs from (0,0) to (1000,1000)

See Also

Logical coordinates


Picture Property

Description

This property is used to import or export a picture to/from the MetaDraw control.

Usage

[form.]MDraw.Picture [= LoadPicture("...")]

SavePicture [form.]MDraw.Picture, FName$

Remarks

When this property is accessed, the current picture is copied into a new VB-compatible picture of a type specified in the PictureType property. The exported image may also be offset using the ExportLeft and ExportTop properties. If the PictureType property is PICTYPE_BITMAP, the ExportWidth and ExportHeight properties determine the exported bitmap size (in pixels). In MetaDraw the ExportOptions property must contain EXOPT_EXPORTRECT flag, when the ExportWidth, ExportHeight properties are used.

When a new picture is assigned to the control, the previous picture is destroyed and the new picture converted into MetaDraw's internal format.

  • Metafiles: All metafile records are converted to proper MetaDraw graphical objects.
  • Bitmaps and icons: An image is created consisting of a single bitmap object.
  • If an empty picture is assigned to this property (using LoadPicture("")), an empty picture will be created with current settings for PicLeft, PicTop, PicWidth, PicHeight, OrigWidth, OrigHeight properties.

After the picture is created, the PicXOfs, PicYOfs properties are set to zero and PicXSize, PicYSize are set to OrigWidth, OrigHeight accordingly (or to PicWidth/PicHeight if no original size is specified).

Note: Only Bitmap, Icon and MetaFiles formats are supported by the Picture property. Use the LoadPicture/SavePicture methods to load/save the picture in other formats.

Setting the EXOPT_CLIPPING flag in the ExportOptions property allows the exported image to be clipped using the ClipLeft, ClipTop, ClipWidth and ClipHeight properties.

You can use the LoadPicture/SavePicture methods with PIC_PICTURE as the second parameter to load/save pictures. These methods work faster than the corresponding VB methods.

** USE the MDPICTURE property instead of the Picture property to transfer a picture from one instance of MetaDraw to another.

Example

' Assign the current MetaDraw picture to a PictureBox
' as a 64x64 bitmap.
MDraw.PictureType = PICTYPE_BITMAP
MDraw.ExportOptions = EXOPT_EXPORTRECT + EXOPT_PIXELS
MDraw.ExportWidth = 64: MDraw.ExportHeight = 64
Picture1.Picture = MDraw.Picture

Data Type

Integer (The Picture Handle)

See also

PictureType property, LoadPicture, SavePicture methods, MDPicture property


PictureTarget Property

Description

The PictureTarget property is implemented for internal MetaDraw purposes and is not intended for use by programmers working with MetaDraw.


PictureChanged Property

Description

A flag representing the status of the picture - whether any changes have been made.

Usage

[form.]MDraw.PictureChanged [= {True|False}]

Remarks

The MetaDraw control sets the PictureChanged property to True when any change is made to the picture (e.g.: moved objects, changed attributes).

Note:The MetaDraw control sets this property to False only when the Picture property has been assigned or read. This Flag may also be programmatically set to False.

Data Type

Integer (Boolean)

See also

Creating a new picture, Editing a picture


PictureClip Property

Description

Using this property you can merge any picture into current picture, or retrieve any object(s) from the current picture.

Usage

[form.]MDraw.PictureClip [= LoadPicture("...")]

Remarks

The PictureClip property may be set directly, or by using the LoadPicture or PasteFromClipboard methods . Regardless of how the PictureClip method is set, the result is the same.

The picture assigned to PictureClip is converted to a graphical object (a container will be created if there are multiple metafile records in the inserted image) and the resulting object is inserted into the current picture using its original size and offset. If the new object does not fit into the picture (larger than the current picture) it is shrunk to fit.

When this property is read, the element(s) of the current picture specified by the Current property will be converted to a VB picture of the type specified by the PictureType property. This can then be saved using the SavePicture statement in Visual Basic or MetaDraw's own SavePicture method.

If the PictureType property is PICTYPE_BITMAP, the ExportWidth and ExportHeight properties determine the resulted bitmap size (in pixels). In MetaDraw the ExportOptions property must contains EXOPT_EXPORTRECT flag, when the ExportWidth, ExportHeight properties are used.

Setting the EXOPT_CLIPPING flag in the ExportOptions property allows the exported image to be clipped using the ClipLeft, ClipTop, ClipWidth and ClipHeight properties.

Example

' The following code creates a new icon based on
' the selected objects and assigns it as a form icon
Private Sub cmdSetCursor_Click()
   If MDraw.ObjCount(OBJ_SELECTED) > 0 Then
      MDraw.PictureType = PICTYPE_ICON
      Form1.Icon = MDraw.PictureClip
      Form1.MouseIcon = MDraw.PictureClip
      Form1.Mousepointer = 99
   End If
End Sub

Data Type

Integer (The Picture Handle)

See also

Merging pictures, Picture property, PictureType property


PictureImage Property

Description

This property serves as a temporary buffer to hold a secondary image.

It is used as the source of images in certain AddObject method calls, and certain Action property settings, and in EditMode ED_IMAGE.

Usage

[form.]MDraw.PictureImage [= LoadPicture("...")]

Remarks

When this property is read, the element(s) of the current picture specified by the Current property will be converted to a VB picture of the type specified by the PictureType property.

In addition to direct setting of the property, the PictureImage may be set by

  • Setting the Action property to ACT_IMAGECOPY, or ACT_IMAGESWAP
  • Calling the LoadPicture method with a destination of PIC_IMAGEPICTURE
  • Calling the PasteFromClipboard method with a destination of PIC_IMAGEPICTURE

The picture referenced by this property will be inserted as a new element as a result of:

  • Drawing with the mouse in EditMode ED_IMAGE
  • Calling the AddObject methods with parameter OT_IMAGE
  • Setting the Action property to ACT_IMAGEINSERT

The PictureImage property may be quickly swapped with the main picture by setting the Action property to ACT_IMAGESWAP.

Data Type

Integer (The Picture Handle)

See also

Creating objects, Action property, Picture property


PictureOptions Property

Description

Specifies additional flags, which determine how to load pictures and display the background.

Usage

[form.]MDraw.PictureOptions [= setting%]

Settings

The PictureOptions property settings are:

Constant | Value | Description
PICOPT_SOLIDMETAFILE | 1 | Load Windows metafiles as a single object – picture.
PICOPT_SOLIDENHMETAFILE | 2 | Load Enhanced Windows metafiles as a single object – picture.
PICOPT_SOLIDMETAFILES | 3 | Load both Windows metafiles and Enhanced metafiles as a single object.
PICOPT_PICTUREBACKGROUND | 16 | The image held by the BackPicture property scrolls and zooms with the main image.
PICOPT_FULLBACKGROUND | 32 | If this flag set, MetaDraw will draw the picture background (BackPicture property) even beyond the extent of the main picture (if the control window is larger than the main picture).
PICOPT_STRETCHBRUSH | 64 | With this flag set, MetaDraw will stretch the picture assigned to the FillPattern property into an 8x8 bitmap. Otherwise the full picture will be used as the brush on WinNT and Win98 machines (or 8x8 top-left corner for Win95).
PICOPT_INVERTDXF | 128 | This flag instructs MetaDraw to invert black and white colors while loading a .DXF file. Otherwise MetaDraw adds black rectangle under the DXF picture. (this can be removed if desired after importing the DXF image).
PICOPT_HIDEINVISIBLE | 256 | When the is set all objects with invisible flag continue to be invisible during edit modes and export operations (ExportDC property). Otherwise such objects are invisible only in ED_View mode.
PICOPT_DXFDEFAULTLIMITS | 512 | This flag instructs MetaDraw to check limits set in DXF file being imported. MetaDraw will recalculate the size of picture during loading to guarantee that all the objects are visible.
PICOPT_DXFVERSION14 | 1024 | Turn this flag on to take advantage of specific AutoCad ver.14 (or higher) features when exporting to DXF format from MetaDraw. This instructs MetaDraw to save in "Enhanced" mode. This is compatible with AutoCAD version 14 only, but allows MetaDraw to preserve additional features of the image. Otherwise, If this flag is clear, MetaDraw saves in AutoCad 10 compatible format.
PICOPT_FOXPROFORM | 2048 | This flag must be turned on when MetaDraw is used in FoxPro environment.
PICOPT_LARGEBRUSH | 4096 | This flag forces MetaDraw to use its own mechanism for drawing patterns. It allows support of any size patterns in Windows 95. If this flag is not set only 8x8 top-left corner of the bitmap will be used on Win 95.
PICOPT_PICTURECLIP | 8192 | This flag forces MetaDraw to Clip objects at the boundary of the MetaDraw picture – hiding any portion which extends beyond the range of the picture coordinate system.
PICOPT_CONVERTROTATED | 16384 | This flag specifies whether to convert simple objects (rectangle, ellipse, ...) which are rotated into polygons when saving in WMF or EMF formats. When NOT set the WorldTransform GDI function is used to rotate objects. This is not supported in WMF, so rotated objects become unrotated after loading them back to MetaDraw. If the PICOPT_CONVERTROTATED flags is set MetaDraw converts rotated objects to polygons, so they look rotated even in WMF files.
PICOPT_EMFFULLFRAME | 16384 | Instructs MetaDraw to consider the EMF records setting the view area for the picture. Otherwise ( if not set) the objects partly lying in the view area are displayed completely.

Remarks

If the PICOPT_SOLIDMETAFILE or PICOPT_SOLIDENHMETAFILE flag is specified in the PictureOptions property, MetaDraw will load/insert the corresponding metafile as one solid object – Picture. This means, that MetaDraw will not parse the distinct objects within the metafile . Use these flags if you insert a metafile that contains some records which are not recognized by MetaDraw (e.g. Clipping, Path records).

When PICOPT_PICTUREBACKGROUND is set and the BackPicture property determines the background image, MetaDraw will draw this image as the main picture background (not as the MetaDraw window background). In that case, the background will be scrolled and zoomed with the MetaDraw picture together.

If the PICOPT_FULLBACKGROUND flag is set, MetaDraw will draw the picture background even outside the picture. Otherwise the background will be clipped by the picture boundaries. This flag is ignored, when the PICOPT_PICTUREBACKGROUND flag is not set.

If PICOPT_INVERTDXF (value is 128) is set in PictureOptions

Then

MetaDraw imports DXF files with a Transparent background
MetaDraw draws uses Black as the Base color for lines

Else

MetaDraw adds a Black rectangle as a background when importing DXF files.
(This rectangle is a standard rectangle object in MetaDraw, placed under other objects imported as part of the DXF image. It can be removed or changed, just like any other object in MetaDraw, after importing the DXF image). MetaDraw draws uses White as the Base color for lines

* * * WARNING - DO NOT save MetaDraw picture to WMF or EMF formats if the image contains an inserted solid metafile in .WMF or .EMF formats Save and load such images only in .MDP format.

The flag value If PICOPT_FOXPROFORM (value is 2048) is designed for use in FoxPro programming environment. FoxPro does not properly support Simple Frame controls and this flag turns off Simple Frames support in MetaDraw. When this flag is set MetaDraw can not be used as a container for other controls - the SimpleFrameSite pointer is destroyed to avoid passing messages to the container where the MetaDraw control is inserted.

The flag PICOPT_PICTURECLIP clips objects which extend beyond the range of the picture coordinate system. If this flag is not set, it is possible that some objects will be displayed going beyond the boundaries.

Example

PicLeft = 0
PicWidth = 1000
PicTop = 0
PicHeight = 1000
AddObject OT_RECTANGLE, 900,100, 1100,200

will draw a rectangle which extends to the right beyond the range of the picture. Setting the PICOPT_PICTURECLIP flag will clip the rectangle at X = 1000.

Example

MetaDraws.PictureOptions = MetaDraw.PictureOptions _
                Or PICOPT_PICTURECLIP _
                And Not PICOPT_HIDEINVISIBLE

Data Type

Integer (BitMask)

See Also

BackPicture property, FillPattern property


PictureType Property

Description

Determines the type of picture to export when reading the Picture, PictureClip properties.

Usage

[form.]MDraw.PictureType [= setting%]

Settings

The PictureType property settings are:

Constant | Value | Description
PICTYPE_DEFAULT | 0 | Automatically determine the picture type.
PICTYPE_BITMAP | 1 | Export picture as bitmap.
PICTYPE_METAFILE | 2 | Export picture as extended metafile.
PICTYPE_ICON | 3 | Export picture as icon.
PICTYPE_PLAINWMF | 4 | Export picture as plain Windows metafile (without comment records).
PICTYPE_ENHMETAFILE | 4 | Export picture as 32-bit enhanced Windows metafile (EMF).
PICTYPE_INTERNAL | 10 | Using internal MetaDraw format.
PICTYPE_DXFFILE | 13 | Picture export in DXF format.

Remarks

If the PictureType property is PICTYPE_BITMAP (1) the ExportWidth and ExportHeight properties determine size of the exported bitmap (flag EXOPT_EXPORTRECT in the ExportOptions property must also be set).

You MUST save images with a PictureType of PICTYPE_METAFILE, PICTYPE_ENHMETAFILE, PICTYPE_INTERNAL in order to preserve the ObjTag, ObjStatus, ObjHotSpot, … characteristics.

Data Type

Integer (Enumerated)

See also

ExportHeight and ExportWidth properties, Picture property, PictureClip property, "Saving Pictures" section


PicWidth Property

Description

See PicLeft, PicTop, PicWidth, PicHeight properties


PicXOfs, PicYOfs Properties

Description

These properties determine the offset of the upper-left corner of the visible area from the upper-left corner of the picture. The offset is measured in units specified by the ScaleUnits property or the parent control's ScaleMode, ScaleLeft, ... properties (which by default are in twips).

Usage

[form.]MDraw.PicXOfs [= X_offset&]

[form.]MDraw.PicYOfs [= Y_offset&]

Remarks

Changing these offsets has the effect of scrolling the picture in the box. These properties are also changed when the picture is manually scrolled by mouse action.

If the ScrollCheck property is True and new values are assigned to PicXOfs, PicYOfs, these values are checked and adjusted as needed to keep the picture inside the box.

Note: These properties can not be changed unless the AutoScale property is set to SCALE_NONE.

Example

' The following code scrolls the MetaDraw picture horizontally.
' Assume that the visible picture is large than the MetaDraw window
Dim delta As Long
Private Sub Form_Load()
   delta = MDraw.PicXSize / 20
   MDraw.ScrollCheck = True
End Sub
Private Sub Timer1_Timer()
   Dim ofsX&
   ofsX& = MDraw.PicXOfs
   MDraw.PicXOfs = MDraw.PicXOfs + delta
   ' If it's unable to scroll, then change the direction
   If MDraw.PicXOfs = ofsX& Then delta = -delta
End Sub

Data Type

Long

See Also

Logical coordinates, Zooming and Scrolling pictures, AutoScale property, ScrollCheck property, ScaleUnits property


PicXSize, PicYSize Properties

Description

The PicXSize and PicYSize properties are the visible height and width of the picture, in units specified by the ScaleUnits property of the parent container's ScaleMode, ScaleLeft, ... properties (which by default are in twips).

Usage

[form.]MDraw.PicXSize [= new_picture_width&]

[form.]MDraw.PicYSize [= new_picture_height&]

Remarks

Changing the PicXSize and PicYSize properties affects the visible size of the picture displayed in the MetaDraw box.

Note: These properties can only be changed when the AutoScale property is SCALE_NONE.

For example, to show the middle of the visible rectangle 1.5 times zoomed, you can write code like this (PicXOfs and PicYOfs are also changed to fix the given point at the center of the box):

' Zoom relative to original size
MDraw.PicXSize = MDraw.OrigWidth * 1.5
MDraw.PicYSize = MDraw.OrigHeight * 1.5
' Zoom relative to current visible size
MDraw.PicXSize = MDraw.PicXSize * 1.5
MDraw.PicYSize = MDraw.PicYSize * 1.5
MDraw.PicXOfs = MDraw.PicXOfs * 1.5
MDraw.PicYOfs = MDraw.PicYOfs * 1.5

If PicXSize and PicYSize properties are set to 0 the picture will not be displayed. In this case the background of the MetaDraw control box will be filled with color that is specified in the PicBorderColor property.

Note: The PicXSize/PicYSize properties have nothing in common with the logical picture units which are specified by the PicLeft, PicTop, PicWidth, PicHeight properties.

Setting the ZoomFactor property maintains the aspect ratio in X and Y diretions and is generally preferred as an alternative to independently setting PicXSize and PicYSize.

Data Type

Long

See Also

Logical coordinates, Zooming and Scrolling pictures, AutoScale property, ScaleUnits property, ZoomFactor property


Redo Method

Description

This method reverses the effect of the last Undo commands.

Usage

Function Redo ([ByVal nLevel As Integer]) As Integer

Returns

The number of commands that have been successfully canceled / reversed

When nLevel is set to 0, the function returns the number of Redo commands stored in Redo buffer.

Remarks

This method reverses / cancels the specified number of most recently performed Undo commands. If the specified value (nLevel parameter) is greater than the number of available commands in Redo buffer, only available redo commands will be executed and the function returns the number of that commands.

The Redo buffer will be erased after any changes ( other than Undo and Redo) in MetaDraw main picture.

Example

MDraw.AddObject OT_ELLIPSE, 100, 100, 200, 300
MDraw.Undo 1 ' delete ellipse
MDraw.Redo 1 ' restore the object

See also

Undo/Redo support, Undo method, UndoLevels property


ReadImageMap Method

Description

This method reads an image from HTML content with the corresponding ImageMap section and converts them into MetaDraw picture.

Declaration

Function ReadImageMap ( Source As Variant _ Ê
Ä ByVal MapName As String [, ByVal PicDst As Long] ) As Long

Syntax

err = [form.]MDraw.ReadImageMap ("ImageMap.htm", "MapName", PIC_PICTURE)

Parameters

This function accepts the following parameters:

Parameter | Description
Source | Specifies the HTML or ImageMap to be read. It can be either string that contains HTML content or URL reference to an HTML file.
MapName | Name of the Map that should be extracted from the HTML content. If it is empty or omitted MetaDraw reads the map section for the first <IMG> tag with USEMAP attribute.
PicSrc (optional) | Identifies how MetaDraw will insert HTML image – as a new picture or into the current picture. It may be one of the following values: PIC_PICTURE – Creates a new picture (default value) PIC_PICTURECLIP – Inserts new objects into the current picture.

Returns

The ReadImageMap method returns error code in case of errors or 0 if ImageMap has been successfully exported.

Remarks

The Source parameter determines where MetaDraw will read HTML content from. It can be either string that contains HTML text or an URL that points to HTML file. In second case URL should always be started with protocol name (http://, ftp:// or file://). If an URL is specified MetaDraw will download and parse the corresponding HTML content.

If there is an <IMG> tag that refers to the specified MAP section (it has "usemap=#<mapname>" attribute) in the HTML file, MetaDraw will also download the corresponding image and insert it as the first object.

All AREAs elements from <MAP> section will be converted to the corresponding MetaDraw object:
POLY- polygon
RECT- rectangle
CIRC- ellipse

By default the ObjStatus property for all objects created from AREA elements will be set to (OS_WEBURL, OS_CURSOR, OS_HOTSPOT) and .ObjVisible will be set to False. The developer can handle MetaDraw's Change event (CHG_OBJECTADD) to operate with new objects added during exporting from the MAP section (e.g. to change their attributes).

Example

' Read ImageMap for the first <IMG> tag with USEMAP attribute
' From the specified HTML file
errno = .ReadImageMap("file://Image.html", "")

' Read HTML content to the str$ string and extract a MAP named <MyMap>
Read #FlNum, str$
ReadImageMap(str$, "MyMap", PIC_PICTURE)

See Also

CreateImageMap method


Redraw Property

Description

This property determines whether or not to repaint picture automatically after any changes.

Usage

[form.]MDraw.Redraw [= {True|False}]

Remarks

If Redraw property is True, picture will be updated after any change (scrolling, resizing, change of an object's attributes, etc).

If Redraw is False, the picture will not be repainted after changes, but the user can repaint it using the Refresh method. Moreover, the picture will be repainted (if it had been changed and Redraw property was False) after assigning the Redraw property to True.

Data Type

Integer (Boolean)

See also

Refresh method


Refresh Method

Description

Update the control at run-time.

Syntax

MDraw.Refresh

Remarks

Use this method for a full picture update. This method can be used to refresh the picture while the Redraw property is False.

See also

Refresh method in the Microsoft Visual Basic Language Reference


RemoveObject Method

Description

Removes object(s) specified by index, or the Current property, from the current picture in the MetaDraw control box.

Syntax

MDraw.RemoveObject [object_handle&]

Settings

The parameter can be one of the following values:

Constant | Value | Description
OBJ_CONTAINER | 1 | Delete all objects in the current open container. If it is not the main container, then it also will be deleted also and the container from the next level up becomes the open container.
OBJ_SELECTED | 2 | Delete all selected objects.
OBJ_CURRENT | 4 | Objects for deleting are specified by Current property.
object_handle& | <Long> | Specifies a valid object handle to be deleted.

Remarks

If the parameter value is OBJ_CURRENT or omitted, the object or group of objects specified by the Current property will be deleted. The Current property may contain either a reserved handle, or the handle of the object (or container) that should be deleted.

After the RemoveObject method has been invoked the Current property contains:

  • OBJ_NULL, if an object handle was specified for deleting;
  • the same value, if a reserved handle was specified.

Example

The following example shows how to delete all polygons in the open container:

Private Sub Command1_Click()
   Dim cur&
   ' Move pointer to first object in open container
   MetaDraw.ObjMove = MOVE_CONT_FIRST
   ' repeat loop while there is one more object
   While MetaDraw.Current > OBJ_VALID
      If MetaDraw.ObjType = OT_POLYGON Then
         ' Save object handle to delete it later
         cur& = MetaDraw.Current
      Else
         ' Don't delete object
         cur& = OBJ_NULL
      End If
      ' Move Current pointer to next object
      MetaDraw.ObjMove = MOVE_NEXT
      If cur& > OBJ_VALID Then
         ' Delete previous object, if it is a polygon
         MetaDraw.RemoveObject cur&
      End If
   Wend
End Sub

See also

Current property


Repaint Property

Description

Determines the painting method for the picture.

Usage

[form.]MDraw.Repaint [= settings%]

Settings

The Repaint property settings are:

Constant | Value | Description
PAINT_NORMAL | 0 | The MetaDraw control will paint the picture as a metafile (redraw object by object).
PAINT_BUFFERED | 1 | The MetaDraw control will use an offscreen bitmap for a fast looking repaint.

Remarks

If Repaint is PAINT_NORMAL then the picture will be drawn to screen immediately.

If Repaint is PAINT_BUFFERED the picture object will first be drawn on a temporary bitmap in memory, after which the resulting bitmap will be drawn on screen.

Note: Don't use PAINT_BUFFERED mode on slow machine. Otherwise, the picture will be drawn very slowly.

Data Type

Integer (Enumerated)

See also

Redraw property


RotateObjects Method

Description

This function rotates object(s), determined by the Current property, around a specified point by a specified angle.

Declaration

Sub RotateObjects (ByVal X As Long, ByVal Y As Long, Ê
Ä ByVal Angle As Single, Ê
Ä ByVal crdType As Integer)

Syntax

MetaDraw.RotateObjects X&, Y&, Angle#, crdType%

Parameters

The RotateObjects method uses these arguments:

Argument | Description
X&, Y& | Determines the point around that the rotation will perform.
Angle# | Determines the rotation angle.
crdType% | Specifies the measurement units for X&, Y& parameters

The crdType% parameter is a BitMask can take on the following values:

Constant | Value | Description
CRD_LOGIC | 0 | All coordinates are in global logical coordinates (picture coordinates).
CRD_LOGIC_LOCAL | 2 | All coordinates are specified in local (container) logical units.
CRD_PIXELS | 4 | All coordinates are in client pixels.

Remarks

This method differs from the ObjRotation property in that rotation may be about any X/Y point.

Unfortunately, non-TrueType text objects can not be rotated by MetaDraw.

If the Current property points to several objects (OBJ_SELECTED), all of them will be rotated around the specified point independently.

See Also

EditMode property, ObjRotation property


RotatePicture Method

Description

This function rotates the entire image (including the background picture).

Declaration

Sub RotatePicture (ByVal nFlags As Integer)

Syntax

MetaDraw.RotatePicture nFlags%

Parameters

The nFlags% parameter accepts the following values:

Value | Description
0 | Rotate Left
1 | Rotate Right
2 | Rotate 180 degrees

Remarks

If the MetaDraw picture has a background image determined by the BackPicture property, it will be also rotated by the specified direction.

Note: For ClearEdge Users: ClearEdge does NOT support rotation of COLOR images, thus you must make sure NOT to have a color image loaded in the ClearEdge background if you are going to use this feature - it would cause a GPF.

See Also

ObjRotation property


SaveData Method

Description

Save MetaDraw contents to a file.

Declaration

Sub SaveData (ByVal FileName As String)

Syntax

MetaDraw.SaveData FName$

Remarks

This function stores all MetaDraw data to the specified file, including control window sizes, attributes, all pictures and so on. The LoadData method can be used to restore the saved data.

Note: Use the .MDR file extension for such files.

See Also

LoadData property


SavePicture Method

Description

Saves MetaDraw's pictures into an external file or database field.

Declaration

Sub SavePicture (ByVal Destination As Variant, ByVal picSrc As Integer Ê
Ä [, ByVal PicType As Integer])

Syntax

MetaDraw.SavePicture Destination, picSrc% [, picType%]

Parameters

SavePicture uses these arguments:

Argument | Description
Destination | Specifies a destination to which picture will be saved. This is a variant and it may be one of the following types:
 | Type | Destination
 | String | A local file name
 | Integer | A valid VB file number (see the VB Open statement)
 | Long | A valid (opened) Windows file handle
 | DAO field | A valid field object of DAO Recordset.
 | ADO field | A valid field object of ADO Recordset.
 | RDO column | A valid column object of RDO Resultset
 | ByteArray | A memory byte array that contains binary data of a picture
picSrc% | Specifies which picture should be saved.You can save the main picture, any set of objects from the main picture, or the temporary buffer image by specifying one of the following values:
 | Constant |  | Value |  | Description
 | PIC_PICTURE |  | 0 |  | Save the entire main picture.
 | PIC_PICTUREIMAGE |  | 1 |  | Save the picture that is determined by the PictureImage property.
 | PIC_PICTURECLIP |  | 2 |  | Save only selected objects.
 | PIC_PICTURECURRENT |  | 3 |  | Save only objects of the main picture whose handle(s) is(are) specified by the Current property.
PicType% | Determines the data format of the stored picture. Use one of the following values:
 | Constant |  |  | Value |  | Description
 | PICTYPE_DEFAULT |  |  | 0 |  | Type of the picture is determined by the PictureType property.
 | PICTYPE_BITMAP |  |  | 1 |  | Save picture as bitmap.
 | PICTYPE_METAFILE |  |  | 2 |  | Save picture as metafile.
 | PICTYPE_ICON |  |  | 3 |  | Save picture as icon.
 | PICTYPE_ENHMETAFILE |  |  | 4 |  | Save picture as EMF (Enhanced Windows Metafile).
 | PICTYPE_INTERNAL |  |  | 10 |  | Save picture as MetaDraw Internal format.
 | PICTYPE_DXFFILE |  |  | 13 |  | Save picture in DXF format.
 | PICTYPE_JPGFILE |  |  | 14 |  | Save picture as JPG image.See also JPGQuality property
 | PICTYPE PNGFILE |  |  | 20 |  | Save picture as PNG.

Returns

This method returns no values, but causes a run-time error in case of errors.

Remarks

Saving in the MetaDraw Internal format is most efficient in terms of speed, and generally most efficient in terms of space with the possible exception of JPG files if the image contains large raster based objects.

The PicType% parameter is optional. If it is omitted, MetaDraw uses the PictureType property to determine the type of stored picture. The user should either specify the type of the picture as the third parameter in the SavePicture method, or using the PictureType property of MetaDraw before calling this method without a 3rd parameter).

Note: The type of picture ( file format) that will be saved depends on the PictureType property or PicType% parameter, NOT on the specified file extension.

If picSrc% is PIC_PICTURECLIP, you should set the value of Current to point to the object(s) you want to save, before calling this method. You can also save a single object from MetaDraw's picture (e.g. bitmap). Just assign its handle into the Current property and call the SavePicture method and specify PIC_PICTURECURRENT as the picSrc% parameter. To save all Selected objects, set the Current property to the special value of OBJ_SELECTED.

When EXPOPT_CLIPPING flag is set in the ExportOptions property then the ClipLeft, ClipTop, ClipWidth and ClipHeight properties determines clipping rectangle to be saved as resulted picture.

When saving a picture in DXF file format the PICOPT_DXFVERSION14 (= 1024) flag of the PictureOptions property determines which version of DXF format will be used.

When saving a picture in JPG format, the compression used is determined by the JPGQuality property.

We recommend use of MetaDraw's SavePicture method instead of the VB SavePicture statement, because it works faster. The following table shows the values of the picSrc% parameter and corresponding using of the VB SavePicture statement:

Value of picSrc% | Corresponding SavePicture statement
PIC_PICTURE | SavePicture MDraw.Picture , "filename.ext"
PIC_PICTURECLIP | SavePicture MDraw.PictureClip, "filename.ext"
PIC_PICTUREIMAGE | SavePicture MDraw.PictureImage, "filename.ext"

Saving to an Image File

To Save to an image file simply specify the FileName as the first parameter of the LoadPicture Method

Saving to an open Sequential File

Specifying a valid open file handle for a sequential file as the destination parameter saves the picture to the current position of the opened file This technique is useful to create a picture library (several pictures saved in one file).

Note: The MetaDraw 2 SavePictureToFile method is obsolete and should no longer be used.

Saving to a Database

MetaDraw is able to save pictures directly to database fields. The referred fields/columns of database table should have long binary value types. Any picture formats supported by MetaDraw can be loaded from or stored to database field (pictures are stored in the database as a byte binary array).

When saving to a database, the SavePicture method only writes the picture to the specified field/column. It is still necessary to call the database Recordset.Update method to commit the changes

Example

' Save selected objects to a JPEG file
   If MetaDraw.ObjCount( OBJ_Selected ) > 0 Then
        MetaDraw.Current = OBJ_SELECTED
        MetaDraw.SavePicture "c:\somefile.jpg", PIC_PICTURECLIP _
            "PICTYPE_JPGFILE
   End If

' Save picture to an ADO database field
   MetaDraw.SavePicture recADO.Fields("PictureData"), _
            PIC_PICTURE, PICTYPE_DEFAULT
   recADO.Update
' Save picture to byte array from one MetaDraw
' and then load from byte array in another MetaDraw
   Dim ByteArray(0) As Byte, varMy As Variant
   varMy = ByteArray
   MD1.SavePicture varMy, 0, PICTYPE_INTERNAL
   MD2.LoadPicture varMy, 0, PICTYPE_INTERNAL

See Also

Saving and Exporting pictures, ExportOptions property ,
LoadPicture method, VB SavePicture statement


SavePictureEx Method

Description

*** THIS METHOD IS OBSOLETE, USE SAVEPICTURE METHOD INSTEAD


SavePictureToFile Method

Description

Saves the MetaDraw's pictures into an external file given a handle.

*** THIS METHOD IS OBSOLETE, USE SAVEPICTURE METHOD INSTEAD


ScaleUnits Property

Description

Returns or sets a value indicating the unit of measurement for some MetaDraw's properties that determine visual sizes (OrigWidth/OrigHeight, PicXSize/PicYSize, ClientWidth/ClientHeight, ClipXXXX).

Syntax

[form.]MDraw.ScaleUnits [= units#

Settings

The settings for this property are

Constant | Value | View
UNITS_CONTAINER | 0 | Specifies that the measurement units are determined by the parent container's properties ScaleMode, ScaleLeft, …
UNITS_TWIPS | 1 | Returned values are in twips (1440 twips per logical inch; 567 twips per logical centimeter).
UNITS_POINTS | 2 | Returned values are in points (72 points per logical inch).
UNITS_PIXELS | 3 | Returned values are in pixels (depends on the current screen resolution)
UNITS_CHARACTERS | 4 | Returned values are in character units (120 twips per unit by horizontal; 240 twips per unit by vertical).
UNITS_INCHES | 5 | Returned values are in inches.
UNITS_MILLIMETERS | 6 | Returned values are in millimeters.
UNITS_CENTIMETERS | 7 | Returned values are in centimeters.
UNITS_HIMETRIC | 8 | Returned values are in HiMetrics (0.01 millimeter per unit).

Remarks

Default value for this property is UNITS_CONTAINER. If the parent container does not support scale units (e.g. in Delphi or .NET environments), MetaDraw always returns values measured in twips.

Example

' The following sample code sets the visible size of
' the MetaDraw picture to (3.5" x 4") inches.
With MetaDraw
    .ScaleUnits = UNITS_INCHES
    .PicXSize = 3.5#
    .PicYSize = 4#
End With

Data Type

Single

See also

Coordinate properties of MetaDraw


Scroll Event

Description

Occurs when the picture size or position is changed, e.g., when the user scrolls the picture (using mouse, keyboard or scrollbars) or if PicXOfs/PicYOfs or PicXSize/PicYSize properties are changed programmatically.

Syntax

Sub MDraw_Scroll ([Index As Integer])

Remarks

The Scroll event occurs before the actual scrolling/scaling is performed, so the code in this event can check and modify PicXOfs/PicYOfs and PicXSize/PicYSize as required. For example, the following code forces the picture to be scrolled diagonally whenever the user tries to scroll it up or down:

Sub MDraw_Scroll()
   MDraw.PicXOfs = MDraw.PicYOfs
End Sub
Note: No recursion occurs when you change any properties of the given MetaDraw control from inside its Scroll event, because a special internal flag is used to prevent nested calls of this event.

See also

Displaying and scrolling the picture


ScrollBars Property

Description

This property determines whether or not to show the scrollbars on the right and bottom sides of the MetaDraw control. Scroll bars allow the user to scroll the picture by clicking the mouse on these bars.

Usage

[form.]MDraw.ScrollBars [= setting%]

Settings

The ScrollBars property settings are:

Constant | Value | Description
BAR_NONE | 0 | No scrollbars are shown.
BAR_AUTO | 1 | (Default) Each of the two scrollbars is automatically enabled if scrolling is possible in the corresponding direction. That is, the horizontal scrollbar is enabled when picture width PicXSize is greater than width of the client area of the control and the vertical bar is enabled when PicYSize is greater than height of the client area. Note that the client rectangle (where you can see the picture) will change its size depending upon which scrollbars are visible.
BAR_ALWAYS | 2 | Both Horizontal and Vertical scrollbars are always visible. However, you still can't scroll if the picture is smaller than the box. The advantage is that the MetaDraw box's client area remains the same for any picture loaded.
BAR_AUTO95 | 3 | The same as BAR_AUTO, but scrollbars are shown in Windows 95 style.
BAR_ALWAYS95 | 4 | The same as BAR_ALWAYS, but scrollbars are shown in Windows 95 style.

Remarks

Whether the scroll bars are enabled or not, the user can scroll (drag) the picture through use of the mouse or keyboard.

Note: The scroll bars do not function in design mode.

Data Type

Integer (enumerated)

See also

Displaying and scrolling the picture


ScrollCheck Property

Description

This property determines whether or not to check visible picture bounds after the picture is scrolled or resized.

Usage

[form.]MDraw.ScrollCheck [= {True|False}]

Setting

The ScrollCheck property settings are:

Setting | Description
True | Enables automatic checking for the visible picture rectangle after the picture is scrolled or resized.
False | Disable any checking after changing PicXOfs, PicYOfs, PicXSize, PicYSize properties.

Remarks

If ScrollCheck is True, and you assign new values to PicXOfs, PicYOfs or PicXSize, PicYSize then these values are checked and adjusted as needed to keep the picture inside the box: negative values are changed to zero, large positive values are adjusted so that the right edge of the picture is at the right edge of the box. If the picture fully fits in the box vertically or horizontally (can't be scrolled in this direction), then the corresponding PicXOfs/PicYOfs property is always zero and the assigning new values have not any effects.

If ScrollCheck property is False, no checks are made. The picture can be placed anywhere in the window or beyond it.

Data Type

Integer (Boolean)

See also

Displaying and scrolling the picture


ScrollKeyboard Property

Description

This property determines whether or not to allow the user to scroll the picture in the control using the keyboard.

Usage

[form.]MDraw.ScrollKeyboard [= {True|False}]

Settings

The ScrollKeyboard property settings are:

Setting | Description
True (default) | Allows the MetaDraw control to scroll the picture by the keyboard.
False | Keyboard scrolling is disabled.

Remarks

When ScrollKeyboard is True and the MetaDraw control has focus, MetaDraw interprets several cursor keys to scroll the picture vertically and horizontally. All keyboard messages for these keys are consumed inside the MetaDraw and do not cause any VB events.

When ScrollKeyboard is False, the default keyboard processing is disabled and the programmer can process any of the cursor keys in the KeyDown/KeyUp and KeyPress events. The following table shows the standard interpretation of the control keys.

Virtual key code | Scrolls | With [Ctrl] pressed
VK_LEFT | 1 pixel left | Window width left
VK_RIGHT | 1 pixel right | Window width right
VK_UP | 1 pixel up | ---
VK_DOWN | 1 pixel down | ---
VK_PRIOR (PgUp) | 'Height' pixels up | To the top of picture
VK_NEXT (PgDn) | 'Height' pixels down | To the bottom of picture
VK_HOME | To the left edge | ---
VK_END | To the right edge | ---

Data Type

Integer (Boolean)

See also

Displaying and scrolling the picture, ScrollBars property, ScrollCheck property, ScrollMouse property


ScrollMouse Property

Description

This property determines how MetaDraw Scrolls and Zooms the picture in response to the mouse.

Usage

[form.]MDraw.ScrollMouse [= scroll_type%

Settings

The ScrollMouse property may be set by combining appropriate flag values using the logical OR operation. Flag values are identified in the table below:

Constant | Value | Description
SCROLL_NONE | 0 | Mouse scrolling is disabled.
SCROLL_RDRAG | 1 | Scroll picture while the right mouse button is pressed and mouse is dragging (default value).
SCROLL_MSCROLL | 2 | Activate picture scrolling when the middle mouse button is pressed. Picture will be scrolled in direction determined by the mouse position.
SCROLL_BOTH | 3 | Combination of SCROLL_RDRAG & SCROLL_MSCROLL flags.
SCROLL_LDRAG | 4 | Scroll picture while the left mouse button is pressed and mouse is dragging.
SCROLL_RSCROLL | 5 | The same as SCROLL_MSCROLL flag, but activated when the right mouse button is pressed.
SCROLL_MDRAG | 6 | Scroll picture while the middle mouse button is pressed and mouse is dragging.
SCROLL_WHEEL | 32 | Scroll picture vertically and horizontally with mouse wheel. To scroll horizontally use Shift key.( Not supported under Windows 95)
SCROLL_WHEELZOOM | 64 | Zoom picture with mouse wheel. Press Ctrl key to enable zooming.( Not supported under Windows 95)

Example

MetaDraw.ScrollMouse = Scroll_Rdrag Or Scroll_Wheel Or Scroll_WheelZoom

Remarks

Even if the mouse scrolling and the scroll bars are all disabled, the picture can still be scrolled at runtime by changing the PicXOfs and PicYOfs properties from the code, and Zoomed using the Zoom, PicXSize, PicYSize, or AutoScale properties.

Customized response to use of the Mouse Wheel may also be achieved by processing of the MouseWheel event.

MetaDraw offers direct Mouse Wheel support only Windows 98, ME, NT4, 2000, and XP. Under Win95 it is necessary to add code to catches Windows Messages and passes them to focused window

Data Type

Integer.

See also

Displaying and scrolling the picture, ScrollBars property, ScrollCheck property, ScrollKeyboard property, MouseWheel event


SetBounds Method

Description

This method sets new boundaries for the object referenced by the Current property.

Declaration

Sub SetBounds (ByVal left% As Integer, ByVal top% As Integer, Ê
Ä ByVal right% As Integer, ByVal bottom% As Integer, Ê
Ä ByVal crdType% As Integer)

Syntax

MetaDRAW.SetBounds left%, top%, right%, bottom%, crdType%

Parameters

The SetBounds method uses these arguments:

Argument | Description
left%, top%, right%, bottom% | Specify new boundaries (bounding rectangle).
crdType% | Specifies the type of coordinates for the left%, top%, right%, bottom% parameters. crdType% can be the following values:
 | Constant | Value | Description
 | CRD_LOGIC | 0 | Use global logical coordinates
 | CRD_LOGIC_LOCAL | 2 | Offsets are specified in local (container) logical units.
 | CRD_PIXELS | 4 | Offsets are specified in client pixels

Remarks

This method causes a run-time error in case of errors.

When applied to Text objects, if the specified Height or Width is 0, MetaDraw will calculate the Height and Width according to the FontSize. Otherwise the FontSize may be adjusted according to the specified Height and Width.

The Current property MUST contain a valid object handle. You can only change boundaries of one object at a time.

Note: This method does not check that the specified coordinates are inside the picture. Thus, the user can set object's boundaries such that it will be outside the picture.

See Also

Logical coordinates, MoveObjects method, GetBounds method, Current property


SetFocus Method

Description

This standard method sets the focus to the MetaDraw control.

Syntax

MDraw.SetFocus

See also

SetFocus method in the Microsoft Visual Basic Language Reference


SetLinkPoint Method

Description

Changes coordinates of starting/ending link points.

Declaration

Sub SetLinkPoint (ByVal Index As Integer, Ê
Ä ByVal X As Long, ByVal Y As Long, Ê
Ä ByVal crdType% As Integer)

Syntax

MetaDraw.SetLinkPoint Index%, X&, Y&, crdType%

Parameters

The SetLinkPoint method uses these arguments:

Argument | Description
Index% | Identifies which link ending is being described.
X&, Y& | Specifies the coordinates where the link ending is anchored.
crdType% | Specifies the measurement units for X&, Y& parameters.

The Index% parameter identifies which link ending is being described:

Constant | Value | Description
LNK_START | 0 | Starting link point
LNK_END | 1 | Ending link point
LNK_BOTH | 2 | Both starting & ending points

Remarks

The coordinates for the link ending point is always relative to the object where that link ending is anchored and lies inside the object's boundaries. Coordinates set outside the object's boundaries will be automatically reset to a valid coordinate.

The type of coordinates in crdType% can be the following values:

Constant | Value | Description
CRD_LOGIC | 0 | All coordinates are in global logical coordinates (picture coordinates).
CRD_LOGIC_LOCAL | 2 | All coordinates are specified in local (container) logical units.
CRD_PIXELS | 4 | All coordinates are in client pixels.

The value in crdType% parameter can be combined (OR'd) with one of the following masks:

Constant | Value | Description
CRD_OFFSET | &H1000 | Offsets from center of the object.
CRD_DEFAULT | &H2000 | Use default point.

If the CRD_OFFSET flag specified, the X&, Y& parameters determine offsets from the center point of object. Otherwise the absolute coordinates.

If the CRD_DEFAULT flag specified, MetaDraw automatically calculates the applicable point (the X&, Y& parameters are ignored in that case).

See Also

Link Attributes


SetParams Method

Description

This method sets/replaces the "additional parameters" of the object referenced by the Current property.

The "additional parameters" of an object specify the:

  • points of a polyline or a polygon
  • rounded corners in a rounded rectangle
  • or starting or ending points of a section, arc or chord.
  • Connection points or bends in a Segmented Link

Declaration

Function GetParams (ByVal FirstPar As Long, ByVal NumPar As Long, Ê
 Ä ByRef PointsArray As Any, Ê
 Ä ByVal CrdType As Integer) As Long

Syntax

MDrawPro.SetParams FirstParam&, NumPar&, PointsArray&, crdType%

Parameters

The SetParams method uses these arguments:

Argument | Description
FirstPar& | Specifies the first parameter to be set.Possible Values for this parameter depend on the object type for which parameters are to be set.
 | LINE: |  | 0, 1 (starting and ending points)
 | ROUNDRECT: |  | 0 - width and height of corner ellipses in units according to the crdType% parameter, 1 - width and height of corner ellipses in 0.01 percent from rectangle width/height (the negative value, -10000, means the full rectangle width/height)
 | SECTOR, ARC, CHORD: |  | 0, 1 - (starting and ending points),
 | POLYLINE, POLYGON: |  | >= 0, the starting point to be set; < 0, the starting point (counted from the endpoint) to be set. –2 references the last point in a polygon, -1 references an insertion point after the last point.
NumPar& | Specifies the number of points to set/deleted:
 | < 0, | the number of points to be deleted (starting from parFirst) - valid only for Polylines and Polygons
 | > 0, | Specifies the number of points in PointsArray to add to the object (if CrdType% includes CRD_ADD), or to replace points in the object, starting with the point identified by FirstPar&
PointsArray | An array of points (x and y coordinates pairs which are Long or Integer). This parameter can be set either to the array itself or to the first element in the array.
crdType% | Specifies the type of coordinates for the PointsArray parameter. crdType% can be set with the following values:
 | Constant |  |  | Value | Description
 | CRD_LOGIC |  |  | 0 | All point's coordinates are specified in global logical coordinates.
 | CRD_LOGIC_LOCAL |  |  | 2 | All point's coordinates are specified in local (container) logical units.
 | CRD_PIXELS |  |  | 4 | All point's coordinates are specified in client pixels.
 | For a polyline or a polygon object, the type of coordinates in crdType% can be combined ( OR'd ) with the following value:
 | Constant |  |  | Value | Description
 | CRD_ADD |  |  | &H200 | Add new points to a polyline or a polygon object. If this mask is not specified, points in a polyline or a polygon will be replaced beginning from the FirstPar% point.

Returns

The SetParams function returns the number of points which remaining in the polygon after the operation.
(0 if there is an error).

Remarks

This method causes a run-time error in case of problems.

The Current property should contain a handle of an object prior to calling this function.

The SetParams method can also be used to automatically remove unnecessary points in Polygons and PolyLines. If the SetParams method is called for Polyline or Polygon object and the first two parameters are zero, then points that meet the following conditions will be removed:

  1. The X/Y coordinates are the same as the previous point.
  2. The Point lies on a line determined by two previous points.

The SetParams method can be used to automatically adjust a segmented link to find a "optimal" path, with a minimal number of bends and attempting to pass around other objects without moving any objects. This is done by calling the SetParams method, with a second parameter ( num points) of 0 ( zero points). In this case, the 1st parameter of the SetParams method may be used for setting distance to objects being bypassed.

Note when modifying points, if the number of points exceeds the number available to be replaced, additional points will be added.

Note: NumPar% specifies the number of integer pairs (x and y coordinates). Therefore, the dimension of the array given the Params% parameter MUST be twice the value of NumPar%.

See Also

GetParams method, Current property


ShowInvisible Property

Description

This property determines whether or not to paint objects whose ObjVisible attribute is False.

Usage

[form.]MDraw.ShowInvisible [= {True|False}]

Settings

The ShowInvisible property settings are:

Setting | Description
True | All objects will be drawn.
False | Only objects which have ObjVisible property set to True will be drawn.

Remarks

Note: This property is only affected when the EditMode property is ED_VIEW (0). Otherwise all object are always visible.

If the container does not have the Visible flag set (The ObjVisible property is False) it will not be displayed, even if any object inside it have Visible flag.

Data Type

Integer (Boolean)

See also

Changing object's attributes, Using Hot-Spot abilities


TabIndex Property

Description

This standard property determines the position of the control within the tab sequence on a given form.

Usage

[form.]MDraw.TabIndex [= numeric_expr%]

Remarks

The valid range is any integer from 0 to (n-1), where n is the number of controls on the form that have a TabIndex property. Assigning a TabIndex value of less than 0 generates an error.

Data Type

Integer

See also

TabIndex property in the Microsoft Visual Basic Language Reference.


TabStop Property

Description

This standard property determines if the control's focus can be reached by tabbing from other controls.

Usage

[form.]MDraw.TabStop [= {True|False}]

Data Type

Integer (Boolean)

See also

TabStop property in the Microsoft Visual Basic Language Reference.


Tag Property

Description

This standard property stores any extra string data needed by the program.

Usage

[form.]MDraw.Tag [= string_expr$]

Data Type

String

See also

Tag property in the Microsoft Visual Basic Language Reference.


Text Property

Description

This property sets or returns the text string for the text object(s) whose handle is specified in the Current property.

Usage

[form.]MDraw.Text [= string$]

Remarks

The text string can contain from 1 to 32767 characters. The text string can not contain NULL characters (Chr(0)).

After assigning a new string to the text object its boundaries will be recalculated according to the FontSize, TextHAlign, TextVAlign properties and previous boundaries.

This property is available only for text objects (ObjType property is OT_TEXT). Attempting to read or write the Text property when .Current points to an object of another type will result in an error "Object is not a Text".

You can use the Chr(13) or Chr(10) characters to make a new line for multi-line text objects. The following sequences of these characters make a new line:

Chr(13)
Chr(10)
Chr(13) + Chr(10).

Example:

MDraw.AddObject OT_TEXT, 100, 100, 600, 300
MDraw.TextStyle = TXT_MULTILINE
MDraw.Text = "First line" + Chr(13) + "Second line"
MDraw.FontSize = -90

Example

The following lines create two text objects (one under another):

Sub cmdAddText_Click ()
   MetaDraw.AddObject OT_TEXT, 10, 10, 10, 10
   MetaDraw.Text = "Blue Line"
   MetaDraw.TextColor = RGB(0, 0, 255)
   ' .Current contains the handle of first text object
   MetaDraw.AddObject OT_TEXT, 10, MetaDraw.ObjBottom, _
                        10, MetaDraw.ObjBottom
   MetaDraw.Text = "Red Line"
   MetaDraw.TextColor = RGB(255, 0, 0)
End Sub

Data Type

String

See also

Changing object's attributes.


TextColor Property

Description

Specifies the color of the characters for the text object.

Usage

[form.]MDraw.TextColor [= color_expression]

Remarks

This property is available only for text objects (ObjType property is OT_TEXT).

Data Type

Long (Color)

See also

Changing object's attributes


TextStyle Property

Description

Specifies the style of a text object.

Usage

[form.]MDraw.TextStyle [= txt_mode%]

Remarks

The TextStyle property settings are:

Constant | Value | Description
TXT_STANDARD | 0 | Standard text. Text string is drawn according to the starting point and text alignments.
TXT_BOUNDED | 1 | Text string is displayed inside the specified rectangle.
TXT_MULTILINE | 2 | Multi-line text. Text string is wrapped to be displayed in the specified rectangle.
TXT_BOXED | 3 | Text string is displayed with a box inside the specified rectangle.

When the TXT_STANDARD style is specified for the text object, its boundaries are calculated automatically (according to the FontSize property) and can not be changed. You can only change the position of the text object (starting point) or text string size (FontSize).

If the TXT_BOUNDED style is specified, the single text string will be displayed inside the specified rectangle. MetaDraw automatically adjusts the FontSize property according to the height of the boundary rectangle and space between characters to fit all characters to the width of the specified rectangle.

When the text style is set to TXT_MULTILINE, MetaDraw draws the text string inside the specified rectangle and wraps lines to fit the width of the rectangle. Wrapped text is aligned inside the rectangle according to the text alignments. Carriage Returns, LineFeed or a combination of the two may be used to force a line break in MultiLine objects.

The TXT_BOXED style provides support for automatically drawing a rectangular box around a text object. The LineColor property determines the color of the box line.

For all Text objects, the BackStyle is Opaque then the BackColor determines the color filling the rectangle behind the text. If BackStyle is transparent then FillStyle and FillColor determine the pattern and color filling the rectangle behind the text.

Including OS_FIXEDBORDER in the ObjStatus property forces borders of a MULTI-LINE text object to remain fixed as text is added during editing. Otherwise, borders will be automatically adjusted when edited text is too large for the existing border. (If text shrinks, borders are not changed. They are changed only when text caret goes outside the borders during editing). By default this flag is NOT set.

Including FS_FILLED flag in the FillStyle property will draw a frame around a Standard text object and fill in the background of the object.

Data Type

Integer (Enumerated)

See also

Text objects


TextHAlign Property

Description

This property determines how text will be aligned in horizontal direction.

Usage

[form.]MDraw.TextHAlign [= settings%]

Settings

The TextHAlign property settings are:

Constant | Value | View
TXT_LEFT | 0 | Text will be aligned to the left side of the bounding rectangle.
TXT_CENTER | 1 | Text will be drawn in the middle of the bounding rectangle.
TXT_RIGHT | 2 | Text will be aligned to the right side of the bounding rectangle.

Remarks

MetaDraw always draws a Standard text object from its starting point and the alignment determines where the text characters will be located relative to the starting point.

This property is helpful when a text object is inserted inside a container and the user changes the container boundaries.

This property is available only for text objects (ObjType property is OT_TEXT).

Example

' This code creates a container with a rectangle and
' two text objects that are joined to the corresponding
' corners of the rectangle.
MDraw.AddObject OT_RECTANGLE, 100, 100, 400, 300
MDraw.ObjSelected = True
MDraw.AddObject OT_TEXT, 100, 100, 100, 120
MDraw.ObjSelected = True
MDraw.TextHAlign = TXT_LEFT
MDraw.TextVAlign = TXT_BOTTOM
MDraw.Text = "Left-Top"
MDraw.AddObject OT_TEXT, 400, 280, 400, 300
MDraw.ObjSelected = True
MDraw.TextHAlign = TXT_RIGHT
MDraw.TextVAlign = TXT_BOTTOM
MDraw.Text = "Right-Bottom"
MDraw.Current = OBJ_SELECTED
MDraw.Action = ACT_GROUP

Data Type

Integer (Enumerated)

See also

Changing object's attributes, TextVAlign property


TextVAlign Property

Description

This property determines how text will be aligned in vertical direction.

Usage

[form.]MDraw.TextVAlign [= settings%]

Settings

The TextVAlign property settings are:

Constant | Value | View
TXT_TOP | 0 | Text will be aligned to the top side of the bounding rectangle.
TXT_CENTER | 1 | Text will be drawn in the middle of the bounding rectangle.
TXT_BOTTOM | 2 | Text will be aligned to the bottom side of the bounding rectangle.
standard text objects only
TXT_BASELINE | 3 | The baseline of a text object will be aligned to the starting point.

Remarks

This property is helpful when a text object is inserted inside a container and the user changes the container boundaries.

This property is available only for text objects (ObjType property is OT_TEXT).

Data Type

Integer (Enumerated)

See also

Changing object's attributes, TextHAlign property


Top Property

Description

See Left, Right, Bottom properties


TransparentBackground Properties

Description

Setting TransparentBackground determines whether the MetaDraw background is transparent.

Usage

[form.]MDraw.TransparentBackground [= bool%]

Values

BS_TRANSPARENT = 0

BS_OPAQUE = 1

Remarks

There may be certain controls which do not show through a transparent MetaDraw. Visual Basic forms and graphic controls (Pictureboxes) function properly with MetaDraw in transparent mode.

Note: Controls, that lie under MetaDraw, may not also be shown, when MetaDraw has a Background picture (determined by the BackPicture property) and it is not transparent.

Data Type

Integer (Boolean)

See Also

BackPicture property


Undo Method

Description

Calling this method rolls back the last changes to the image.

Usage

Function Undo ([ByVal nLevel As Integer]) As Integer

Parameters

The nLevel value determines how many undo command should be executed.

Returns

The number of commands that have been successfully rollbacked.

When nLevel is set to 0, the function returns the number of commands stored in Undo buffer.

Remarks

If the number of commands in Undo buffer is less then specified nLevel value, only existing Undo commands will be performed and the function returns the number of that commands.

Each performed Undo command will be added to redo buffer that allows reversing the effects of the Undo commands.

The UnDo of a Delete operation will not preserve the original value of the .Current property assigned to deleted and undeleted objects.

Example

MDraw.AddObject OT_RECTANGLE, 100, 100, 200, 200
MDraw.SetBounds 200, 200, 300, 300, CRD_LOGIC
MDraw.Undo 1 ' restore previous bounds

See also

Undo/Redo support, Redo method, UndoGrouping property, UndoLevels property


UndoLevels Property

Description

Determines the maximum number of possible operations that Metadraw can store for purposes of UnDo / ReDo.

Usage

[form.]MDraw.UndoLevels [= <levels%>]

Default Value

0 – No actions will be added to UnDo buffer

Remarks

This property specifies the maximum number of changes / operations performed upon an Metadraw image, that will be buffered by MetaDraw in support of Undo operations.

Setting UnDoLevels to 0 pauses the adding of changes in the UnDo buffer.
Actions already in the UnDo buffer may still be UnDone by calling the UnDo method.

Example

Example 1
' Set Undo level to remember two most recent commands
MDraw.UndoLevels = 2
MDraw.AddObject OT_RECTANGLE, 100, 100, 200, 200
MDraw.AddObject OT_RECTANGLE, 400, 100, 500, 200
MDraw.AddObject OT_RECTANGLE, 100, 300, 200, 400
MDraw.Undo 3 ' only two last added objects will be removed
Example 2
UnDoLevels = 100   ' allow up to 100 UnDo actions
AddObject OT_Line, 50,50,75,75
UnDoLevels = 0     ' Pause undo Buffer
                   ' Do not add following actions to UnDo buffer
AddObject OT_Rectangle, 100,100,150,150
UnDoLevels = 100   ' Resume adding to UnDo buffer
AddObject OT_Ellipse, 200,100, 250, 100
UnDo 2             ' Remove Ellipse & Line, Rectangle remains

Data Type

Integer

See also

Undo/Redo support, Undo method


UndoGrouping Property

Description

The UnDoGrouping property provides a mechanism to group multiple actions (changes to the MetaDraw image) into a single step for purposes of UnDo and ReDo operations.

Usage

[form.]MDraw. UndoGrouping [= <bool%>]

Remarks

After UndoGrouping is set to True all changes will be stored as one Undo command. This allows you to undo several changes in one step (e.g. it is useful when you need to change object's attributes).

Note: When UndoGrouping is active (True) UndoLevel value is ignored and all changes will be stored unless UndoGrouping is set to False.

Example

Example 1 –
MDraw.UndoLevels = 10  ' Activate Undo ( remember 10 recent steps)
MDraw.UndoGrouping = True
MDraw.LineWidth = 8
MDraw.LineColor = vbRed
MDraw.FillColor = vbGreen
MDraw.UndoGrouping = False
MDraw.Undo 1 ' restore object's colors and border width
Example 2 –
' For user in editmode drawing rectangles or ellipses,
' We start UndoGrouping here in MouseDown event
'    when user starts drawing new object
' and close the UndoGrouping in MouseUp after setting parameters.
' A single UnDo step will now undo both the parameters and the object
Sub MetaDraw1_MouseDown(Button As Integer, Shift As Integer,  _
                        X As Single, Y As Single)
   MetaDraw1.UndoGrouping = True
End Sub
Sub MetaDraw1_MouseUp(Button As Integer, Shift As Integer,   _
                      X As Single, Y As Single)
   With MetaDraw1
     'MetaDraw1.UndoGrouping = True
     .LineColor = RGB(255, 0, 0)
     .FillColor = RGB(255, 255, 0)
     .BackColor = RGB(255, 0, 0)
     .TextColor = RGB(255, 0, 0)
     .UndoGrouping = False
   End With
End Sub

Data Type

Boolean

See also

Undo/Redo support, Undo method


Vectorization Method

† This feature requires MetaDraw Vectorization License Option …

Description

This function finds all areas of uniform color in a bitmap picture and converts them to polygons. If a resulting polygon / polyline is less than nMinPointSize in pixels using the original scale, that object will be ignored (not added to metafile).

Declaration

Function Vectorize (ByVal Picture As Picture, Ê
Ä ByVal MinPointSize As Long) As Picture

Parameters

The Vectorize method uses these arguments:

Argument | Description
Picture | Picture object that contains original bitmap to be vectorized.
nMinPointSize& | Determines the minimal number of pixels of objects converted in polygons. If object consists of less than specified pixels this object will not be added into resulted metafile.

Returns

The Vectorization method returns a metafile picture containing polygons.

The function returns NULL picture in case of errors.

Remarks

Before vectorizing an image it is recommended to remove noise and to reduce colors to less than 256 colors

This function applies only to raster images (BMP, JPG, PNG) before conversion to vector format).

MetaDraw's Vectorization algorithm is best suited to vectorizing images such as color maps where regions of different colors must be converted to polygons. MetaDraw vectorization is not generally suitable for CAD drawings (development partners/sponsors are invited to discuss options for extending support to CAD and Line Drawings).

Example

MetaDraw.Picture = MetaDraw.Vectorization (MetaDraw.Picture, 3)

See also

ColorReduction Method, NoiseReduction Method


Version Property

Description

The Version property returns a value representing the version of the control
Read-only at run-time.

The Version number returned is computed as follows:

Version = 10000 * MajorVersion +  1000* MinorVersion  + BuildNumber.

Example:

If an OCX is version Version 3.4.25 , then the Version property would return decimal value of 35025.

Notes

The Version may also be read at Design Time by double clicking on the About property in the design time properties window.

The Version can also be read by right clicking on the MDRAW30.OCX file in Windows Explorer and selecting "properties" from the context menu.


Visible Property

Description

This standard property determines whether the MetaDraw control is visible or hidden.

Usage

[form.]MDraw.Visible [= {True|False}]

Data Type

Integer (Boolean)

See also

Visible property in the Microsoft Visual Basic Language Reference


WebGoBack, WebGoForward methods

Description

Navigates to the Previous or Next item in the history list.

Syntax

[form.]MetaDraw.WebGoBack

[form.]MetaDraw.WebGoForward

Remarks

These methods call the previous or next URL in the URL history list of the current Web browser.

See also

Working with the Internet


WebNavigate method

Description

Calling this method instructs the web browser to navigate to a document specified by a URL.

Declaration

Sub WebNavigate (ByVal URL As String, Ê

Ä ByVal TargetFrameName As String, ByVal Flags As Integer)

Syntax

[form.]MetaDraw.WebNavigate URL$, "bennet-tec", 0

Remarks

The WebNavigate method parameters include:

Part | Description
URL | A string expression that evaluates to the URL of the resource that the browser is to display.
TargetFrameName | A string expression specifying the name of a frame in which to display the resource. This string can be empty.
Flags | A constant or value that specifies whether to display the resource in a new window. It is one of these values:
 | Value | Meaning
 | 0 | (Default) Open in the current window.
 | 1 | Open in a new window.

See also

Working with the Internet


WebTargetFrame Property

Description

The WebTargetFrame property specifies the name of the frame in which to display the Web document loaded in response to clicking a hotspot for an object with the ObjStatus flag of OS_WEBURL.

Syntax

[form.]MetaDraw.WebTargetFrame [ = string$ ]

Data Type

String

See also

Working with the Internet


WebURLBase Property

Description

MetaDraw adds the contents of the ObjURL property to the value of the WebURLBase property to construct a full URL.

Syntax

[form.]MetaDraw.WebURLBase [ = string$ ]

Data Type

String

See also

Working with the Internet


Width Property

Description

This standard property contains the width of the MetaDraw control.

Syntax

[form.]MDraw.Width [= numeric_expr]

Data Type

Single

See also

Width property in the Microsoft Visual Basic Language Reference


ZoomCentering Property

Description

The ZoomCentering property determines who to scroll picture when its scale factor is changed.

Syntax

[form.]MetaDraw.ZoomCentering [= bool%]

Remarks

If the ZoomCentering property setting is True MetaDraw will zoom the picture so its visible center will be kept in the center of the MetaDraw window.

When this property is False, MetaDraw pins the top left corner of the visible area.

Example

' Keep the visible center of MetaDraw picture in
' the center of visible area
MetaDraw.ZoomCentering = True
MetaDraw.ZoomFactor = 2    ' display image at 2 x original size

See also

Original Unzoomed Size, ZoomFactor property


ZoomFactor Property

Description

The ZoomFactor property can be set to increase or decrease the visible size of the image on screen. Setting the ZoomFactor causes MetaDraw to display the image at the specified multiple of the original size.

Syntax

[form.]MetaDraw.ZoomFactor [= scale#]

Example

MetaDraw.ZoomFactor =  1    ' display image at original size
MetaDraw.ZoomFactor = 0.60  ' display image at 60% of original size
MetaDraw.ZoomFactor =  2    ' display image at 2 x original size

Remarks

This is a Write Only property.

The original size used as the base setting (ZoomFactor = 1 ) is specified by the OrigWidth and OrigHeight properties

Setting the ZoomFactor automatically resets the AutoScale property to SCALE_NONE, and updates PicXSize and PicYSize

It is also possible to Zoom in X and Y directions separately using the PicXSize and PicYSize properties.

See also

Original Unzoomed Size, PicXSize, PicYSize, OrigWidth, OrigHeight properties


ZOrder Method

Description

This standard method places a control at the front or back of the z-order within its graphical level.

Syntax

MDraw.ZOrder

See also

ZOrder method in the Microsoft Visual Basic Language Reference


Trappable Errors

A number of trappable errors can occur during the operation of MetaDraw. If you do not trap these errors, your application will close after displaying an error message. You can use the standard Visual Basic Err function to test which error has occurred, as shown in the following example:

On Error Goto E1
. . . ' (some action involving MetaDraw)
Exit Sub

E1:
Select Case Err
Case MDERR_INVALIDHANDLE
. . . ' (code for recovering from error)
End Select

For more information about trapping errors in Visual Basic, see the Visual Basic Programmer's Guide.

The following table lists the trappable errors for the MetaDraw control.

Error#ConstantMessage and Explanation

387VBERR_CANTSETPROP"'???' property can't be set on this control"
This is a standard Visual Basic error. It occurs when you attempt to change one of the properties which are generally writable, but not in this particular state of the given control.

24000VBERR_NOSELECTION"There are no selected objects"
You are trying to invoke an action which requires objects to be selected (e.g. grouping objects), but no objects are selected.

24001VBERR_INVALIDHANDLE"Invalid object handle"
The handle specified in the Current property is not a valid object handle or the Current property contains one of the reserved handles which are not allowed for the implemented action.

24002VBERR_INVALIDTYPE"Invalid object type"
The second parameter of the AddObject method does not refer to a valid object type.

24003VBERR_INVALIDINDEX"Invalid index"
An incorrect index was specified in the RemoveObject method or while reading the property ObjCount.

24005VBERR_BADMETAFILE"Metafile format error"
The MetaDraw control found a bad metafile record during conversion of the metafile into the MetaDraw's internal format.

24006VBERR_NOTCONTAINER"Object is not a container"
The Current property does not contain a handle of a valid container. For example, you are trying to set the Current pointer to the first child of the container by assigning the ObjMove property to MOVE_CHILD_FIRST, but the Current property did not contain either the reserved handle OBJ_CONTAINER or a handle of the container.

24007VBERR_NOTTEXT"Object is not a Text"
You are attempting to make an action which is allowed only for Text objects. For example, you have tried reading or writing the Text property while Current pointed to a Polyline object.

24008VBERR_NOPICTURE"Picture was not defined"
A picture was not defined in the PictureImage property when image operations were invoked (e.g. insert image to the current picture using AddObject method with OT_IMAGE parameter).

24009VBERR_CANTDELETE"Object can not be deleted"
You are trying to delete the main container in the RemoveObject method. The main container cannot be deleted, but you can delete all objects in the main container using the Clear method.

24010VBERR_CANTOPEN"Object can not be opened"
You are trying to open an object that cannot be opened by assigning True to the ObjOpened property. Only the following objects can be opened: Container, RoundedRectangle, Arc, Pie, Chord, Polyline, Polygon.

24011VBERR_INVALIDPICTYPE"Invalid or unknown picture type"
This error occurs when the picDst% or picSrc% parameter passed to LoadPicture/ SavePicture methods has an invalid value (negative or greater than 2).

24012VBERR_INVALIDFONT"Invalid font name"
You are trying to assign a font name that is not registered in Windows environment.


Metafile Restrictions

The MetaDraw control operates with graphical objects which are determined by the special internal format. It needs to convert metafile records into corresponding objects. Usually, there are no problems during the transformation, however the MetaDraw control has some restrictions for converting a metafile into its own internal format:

  1. If there are a few records for META_SETWINDOWORG and META_SETWINDOWEXT in the metafile, only first pair will be accepted. The picture can be distorted if the metafile contains more than one records META_SETWINDOWORG or META_SETWINDOWEXT
  2. A value of the META_SETMAPMODE record is used only to determine the physical sizes of the picture (if they were not specified in the metafile header).
  3. All records which specify a clipping region (like META_INTERSECLIPRECT, META_SELECTCLIPREGION and so on) are ignored.
  4. Records which work with regions (META_FILLREGION, META_FRAMEREGION and so on) are ignored.
  5. Records which fill an area of the screen surface (META_FLOODFILL, META_EXTFLOODFILL) are ignored.
  6. Records which work with logical palette (META_REALIZEPALETTE, META_RESIZEPALETTE and so on) are ignored.
  7. MetaDraw works only with polygons in ALTERNATE polygon-filling mode. Therefore, the record META_SETPOLYFILLMODE is ignored.
  8. The text which is specified by META_DRAWTEXT (DrawText function) is converted to a one line text string. All text objects will be drawn using the ExtTextOut() GDI function.
  9. Device-dependent bitmaps that are drawn by META_BITBLT, META_STRETCHBLT records will be converted into DIB using the current realized palette.

The coordinates which are specified in the metafile record will be used for creating the corresponding object. The boundary of the new picture is the smallest rectangle which contains the boundaries of all objects. The picture logical coordinates (like PicLeft, PicTop, PicWidth and PicHeight) are calculated as an intersection of this rectangle and the rectangle determined by the META_SETWINDOWORG and META_SETWINDOWEXT records.

The MetaDraw control supports the extended metafile format (using META_ESCAPE records), which allows you to save additional information about objects (object's flags, container structure, tag information, ...). You can export a metafile without additional information by setting the PictureType property to the value PICTYPE_PLAINWMF.


DXF Support Notes

Optional DXF Support Licenses provide support for Reading and Writing DXF format files

The DXF Import Support License enables the Reading of DXF formatted files.

The DXF Export Support License enables the Writing of DXF formatted files.

DXF support is only available to customers purchasing the DXF filter license.

For evaluation purposes, potential users of DXF support may use the HSEditor Utility to Import and Export DXF files prior to purchasing a MetaDraw DXF Import or Export license.

More:

DXF General Usage notes:

Features and Limitations of the DXF IMPORT support:

XDATA and Object Tags

Features and Limitations of the DXF Export support:

ENHANCED mode - Export Conversions

DRAFT mode – Export Conversions

Object TAGS / XDATA


DXF General Usage notes:

DXF support is built into the MDraw32P.OCX file and does not require any additional DLL's, however support is provided only to DXF Licensed developers - Support is enabled by the licensing of an appropriate Serial Number coded to provide DXF support.

To Read and Write DXF Files use MetaDraw's LoadPicture and SavePicture methods

MetaDraw.LoadPicture   filename, PictureSource
MetaDraw.SavePicture   filename, PictureSource, PicType_DXFFile

where PictureSource is Pic_Picture, Pic_PictureClip, or Pic_PictureImage

The PICOPT_INVERTDXF flag of the PictureOptions property controls the background and color support for imported DXF files. By default MetaDraw always adds black rectangle under the DXF picture. (this can be removed if desired after importing the DXF image).

Setting the PICOPT_INVERTDXF flag in the PictureOptions property instead instructs MetaDraw to invert black and white colors while loading a .DXF file and do not add black rectangle under the DXF picture.

For best results in saving DXF files, set the PICOPT_DXFVERSION14 flag in the PictureOptions property before saving a DXF file. This instructs MetaDraw to save in "Enhanced" mode. This is compatible with AutoCAD version 14 only, but allows MetaDraw to preserve additional features of the image. If this flag is clear, MetaDraw saves in AutoCad 10 compatible format.

The PICOPT_DXFDEFAULTLIMITS flag of the PictureOptions property instructs MetaDraw to recalculate the size of picture during loading to guarantee that all the objects are visible. Because it can override some CAD settings for picture layout this flag is optional.

It is possible to define default font attributes for text objects. Before loading .DXF file (calling the LoadPicture method) you can change the default font for MetaDraw's picture as follows:

MDraw.Current = OBJ_DEFAULT
MDraw.FontName = "Arial Greek"
MDraw.FontBold = True
MDraw.LoadPicture "<some_file>

International Support - Any single-byte character with code greater than 128 (international

characters) can be stored to a DXF file. But they will be displayed correctly only if a font with the corresponding character set is assigned to such text upon loading the DXF file. Because DXF is a text-dependent format MetaDraw doesn't support DBCS or UNICODE for DXF export at all.

Reading and Resaving a DXF file will cause the loss of features not supported by MetaDraw.


Features and Limitations of the DXF IMPORT support:

MetaDraw DXF supports the reading of DXF files as generated by AutoCad versions 10 through 14.

MetaDraw DXF recognizes the following DXF record types:

POINT, LINE, RECTANGLE, POLYLINE, ARC VERTEX ,
CIRCLE, ELLIPSE, ARC, TEXT, MTEXT, SOLID,
XLINE, RAY, LWPOLYLINE, INSERT (BLOCK)

Support for other records may be added later.

In particular the following records are NOT currently supported

TRACE, DIMENSION LINES.

Only 2-dimensional DXF images are recognized.

The third axis (Z coordinate) will be ignored when reading 3-D DXF images

All text primitives are converted into text objects using appropriate size (from the DXF file) and the current default font defined in MetaDraw. Text attributes (fontName, bold, italic, underline) are recognized only for MTEXT records when reading a DXF file. Before importing a DXF file default text attributes can be changed to desired values using the corresponding properties. All text objects imported from a DXF file will be created with the same specified text attributes (except font size and rotation angle, which are specified by DXF records).

Point objects are interpreted as Line objects where the starting and ending points are the same.

Polylines are converted into a set of lines and arcs;

Straight-line segments will be converted to standard PolyLines objects.

Curved lines will be converted to arcs.

Polygons are treated as Closed PolyLines.

The MetaDraw DXF import filter recognizes the following DXF object attributes: Line Width, Color, Angle, and Extended Data (represented as object's tag in MetaDraw );

Every DXF layer becomes a separate container (grouped objects) in MetaDraw.


XDATA and Object Tags

MetaDraw can read AutoCAD extended data for DXF files created in ACAD environments with the XDATA command. (only the following types are supported: Int, Long, Real, Str). Because ACAD extended data with different types can have the same name, MetaDraw uses the following mechanism for interpretation:

An extended data sequence will be converted to an object tag with the same name and the corresponding type.

If there is an ambiguity (there are several extended data sequences with the same name but different types) in extended data, MetaDraw adds special prefix to the name of each double-named tag – type of tag. For example, if there are two extended data records named as "SOME_NAME" and with INT and REAL types assigned for an object in a DXF file, MetaDraw creates the following Tags for the corresponding object:

"SOME_NAME" (integer)

"SOME_NAMEDOUBLE" (real).

CURRENT LIMITATIONS:

  • font name and font type are supported only for MText records - not for standard Text records, (MetaDraw uses it's default font name setting to for all Text read from a DXF file).
  • line type is not supported,
  • all objects are recognized as transparent (HATCH is not supported ),
  • Starting with build 2.5.011 MetaDraw supports insertion of Multilevel block when reading DXF files
  • MetaDraw does not recognize AutoCAD's "Frozen" layer attribute and imports all layers the same way.
  • MetaDraw ignores the visible attribute during import of with DXFs, i.e. all the invisible layers become visible containers in MetaDraw


Features and Limitations of the DXF Export support:

MetaDraw provides two modes of DXF export support.

  • "Draft" DXF files - These are basic DXF files compatible with most versions of AutoCAD. But objects in such DXF files can lose some attributes.
  • "Enhanced" DXF files - Compatible with AutoCAD version 14 only. In this mode MetaDraw makes use some of the newer features of DXF format to preserve the image as created in MetaDraw to the maximum extent possible. To save in "Enhanced" mode set the PICOPT_DXFVERSION14 flag in the PictureOptions property.

LIMITATIONS:

Both Draft and Enhanced modes have the following limitations:

  1. All MetaDraw objects (except Polyline and Polygon) have the same line width – 1 pixel;
  2. Line Style for all MetaDraw objects (except Polyline and Polygon) is always SOLID (DASH and DOTTED styles are not supported).
  3. MetaDraw objects have no fill and are represented as TRANSPARENT (except Polygon);
  4. MetaDraw does not support Visible attribute for DXF files - All invisible objects become visible when exported to DXF.
  5. Colors of MetaDraw objects will be approximated to a nearest color in predefined color table (8 standard colors).
  6. Bitmaps are ignored (they will be excluded from the saved file)
  7. Links are converted to polyline objects (the nature of automatic link is not preserved)
  8. HotSpot Information is not preserved on Export to DXF format, Neither are ObjVisible nor ObjURL properties.
  9. During Export, some objects are converted to objects of other types for a more optimal and full representation of data in the DXF format. Refer to the Tables below identifying object conversions in Enhanced and Draft
  10. Please note that a polyline object may have line width and line type in DXF. So all the objects transformed into polylines during export preserve their line width and type settings. All the other objects which preserve their type and are not converted to polylines will have the SOLID line type and ZERO line width (-1 pixel).

The following features are available in the enhanced export mode only:

  1. Filling of a polygon can be stored to a DXF file (solid colors only). In DXF file it is represented as a HATCH object;
  2. Line width and style (DOTTED and DASHED) of a polygon/polyline can be stored in a DXF file;
  3. The following text object attributes are stored in MTEXT record: FontName, FontBold, FontItalic, FontUnderlined.
  4. In Draft mode, MetaDraw only stores text size and rotation angle for text objects. All other text attributes (font names, bold, italic) will be lost.
  5. All text objects will be stored as multi-line text (stored with their boundaries).
    In draft mode all MultiLine text objects will be converted to single line text objects in DXF format.


ENHANCED mode - Export Conversions

The following table shows the correspondence between MetaDraw objects and the associated ACAD objects (DXF records) when saving DXF files in enhanced export mode:

METADRAW | DXF RECORD
Line | LWPOLYLINE
Rectangle | LWPOLYLINE with straight segments
Rounded rectangle | LWPOLYLINE with circular segments
Ellipse | ELLIPSE
Ellipse with zero sizes | POINT
Arc (part of circle) | ARC
Arc (part of ellipse) | ELLIPSE with specified angles
Chord (part of circle) | ARC + LWPOLYLINE
Chord (part of ellipse) | ELLIPSE with specified angles + LWPOLYLINE
Pie (part of circle) | ARC + LWPOLYLINE
Pie (part of ellipse) | ELLIPSE with specified angles + LWPOLYLINE
Polyline | LWPOLYLINE
Polygon | LWPOLYLINE(closed)
DimLine | LWPOLYLINE(set of straight lines)
Text | MTEXT
Container | Layer


DRAFT mode - Export Conversions

DRAFT mode – Export Conversions

The following table shows the correspondence between MetaDraw objects and the associated ACAD objects (DXF records) when saving version 10 compatible DXF files for DRAFT export mode:

METADRAW | DXF RECORD
Line | POLYLINE with two VERTICES
Rectangle | POLYLINE with straight segments
Rounded rectangle | POLYLINE with circular segments
Ellipse | ELLIPSE
Ellipse with zero sizes | POINT
Arc (part of circle) | ARC
Arc (part of ellipse) | ELLIPSE with specified angles
Chord (part of circle) | ARC + POLYLINE
Chord (part of ellipse) | ELLIPSE with specified angles + POLYLINE
Pie (part of circle) | ARC + POLYLINE
Pie (part of ellipse) | ELLIPSE with specified angles + POLYLINE
Polyline | POLYLINE
Polygon | POLYLINE (closed)
DimLine | POLYLINE
Text | TEXT (STANDARD)


Object TAGS / XDATA

MetaDraw object tags are represented in DXF files as Extended Application Data and may be reproduced in ACAD environments with XDATA and XDLIST commands.

MetaDraw stores only tags with the following predefined names:

DXFTAGDEFAULT (default tag string specified by the ObjTag property)

DXFTAG0

DXFTAG1

. . .

DXFTAG9

Tags with other names are ignored - they are not included in the exported DXF file.

Each of this tags can be one of the following types: ShortInteger, Long, Float, Double, String.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Other Notes

Text objects from external applications

When reading Text objects from MetaFiles created by applications where the text height is saved as 0, Metadraw will use the default value for font size.

Closed Curves – PolyLines and Beziers

Setting the LineStyle property applied to a Bezier or Polyline object to include the PS_CLOSED flag bit ( OR'g this bit with a valid line style) will close the shape – The starting and Ending points will be connectedfor a Bezier or PolyLine object A PS_CLOSED flag is now supported for the LineStyle property

Coordinate Properties as Pixels for Environments ( such as .NET) not supporting a ScaleMode

To avoid problems with coordinate properties in .NET, MetaDraw returns

them in pixels if container does not support scale mode.


Trouble Shooting Tips

Technical Support

Technical Support questions may be sent

By e-mail: to Support_MetaDraw@Bennet-Tec.Com

Or by submission to the Bennet-Tec web site Support page

Please include the following with all support requests:

Your Full Name

Full Name of Developer working with MetaDraw if different

Your MetaDraw License Serial Number ( or let us know if you are working in evaluation mode prior to purchasing a license)

The exact version of the MetaDraw control you are working with – example 2.5.025, or 3.0.01

A short summary of the issue

A description of the problem and details on exactly how to reproduce it.

What it is you are trying to achieve ( perhaps an alternative approach can be suggested if we know your objective).

A ZIP file containing any screenshots showing how the problem may appear to you on your system, and any code for a SMALL sample which reproduces the problem. This sample must be simple – just enough to reproduce the problem without any extra code not directly related to the problem. Please do not include databases, multiple forms or dialogs, additional controls, or other logic and code which is not directly related to the issue at hand. Please do not send code or image files except within a single ZIP file as an attachment.


Help Contents

Contents

CHAPTER 1 Introduction

What is MetaDraw ?

Potential Applications of MetaDraw

On-Line Help

HotSpot Editor (HSEditor)

License Options

CHAPTER 2 Getting Started MetaDraw and Various Design Environments

Supported Development Environments

Supported Operating Systems

Distributing Applications

Installation

Sample Applications

Using MetaDraw in Visual Basic

Using MetaDraw in C++

Using MetaDraw in Delphi

Using MetaDraw in Microsoft Access

Using MetaDraw in Visual FoxPro

Using MetaDraw on a Web Page ( HTML)

CHAPTER 3 Concepts

The MetaDraw Picture

Image and Control Size

MetaDraw Coordinate System

Picture Organization - Graphic Objects and Containers

The Control Area vs The Drawing Area

File Formats

CHAPTER 4 Basic Programming Techniques / How To …

Loading an Existing Picture

Initializing a New Image / Setting Active Drawing Size

Saving Pictures

Zooming and Scrolling pictures

Editing an Image

Converting File Formats

Support of UnDo / ReDo

Printing with MetaDraw

Using HyperGraphic Hot-Spots

Working with the Internet

Drag-and-Drop operations

How to count and loop through objects in an image

How to search for objects within MetaDraw

How to create and manipulate diagram links

How to Optimize Diagram Layout

How to set and manipulate the Background

How to create transparent bitmap objects

How to Add Object Shadows

How to work with FloodFills

How to specify a grid

How to Cut, Copy, and Paste

How to Add, Remove or Change Points ( Verticies) in a Polygon or PolyLine

How to use MetaDraw with a database

How to Vectorize an Image

How to work with embedded controls

How to Maximize Performance ( speed)

CHAPTER 5 Advanced Programming Techniques / Application Specific Tips

Writing a HotSpot and Painting Application

Using HSEditor for Creating HotSpot Images

Writing an application for Image Viewing

Writing an application for Image Annotation

Writing an application for Label Generation

Writing an application for Labels with Bar Codes

Writing an application for Diagramming

Writing an application for Graphing

Writing an application for Flow Charting

Writing an application for Floor Plan Layout

Writing an application for Data Mapping

Writing an application for Interactive Graphic Interfaces

Writing an application for Animation

Writing an application for Report Generation

CHAPTER 6 MetaDraw Reference

General Information

Properties

Events

Methods

Detailed Specifications

Appendix A Trappable Errors

Trappable Errors

Appendix B Metafile Restrictions

Metafile Restrictions

Appendix C DXF Support Notes

DXF Support Notes

Appendix D Other Notes

Other Notes

Appendix E Trouble Shooting Tips

Trouble Shooting Tips