Metafile Object
Parents Children Properties Methods Events
Purpose: This object represents a picture in Windows Metafile format.

Description

The Windows Metafile is a mechanism for representing a picture in terms of a collection of graphical components. Windows Metafiles are distributed in special files (.WMF) from which they are loaded into memory for use by an application. Once loaded a Metafile is a Windows "resource" that can be used in a variety of ways. The Metafile object represents this resource.

The File property specifies the name of a .WMF file from which the Metafile is to be loaded or to which it is to be saved. If you specify File with ⎕WC the Metafile object is loaded from it. If you specify File with ⎕WS no action takes place until you instruct the Metafile object to re-initialise itself from the file or to save itself to the file. These operations are performed using the FileRead and FileWrite methods. If you omit the File property in the argument to ⎕WC or if you specify a null vector, the Metafile object is initially empty. The following example loads the picture defined by the GOLF.WMF Metafile that is distributed with Microsoft Office.

      'GOLF' ⎕WC 'Metafile' 'C:\MSOFFICE\CLIPART\GOLF'

Whether or not the Metafile object is initialised from a file, you can add graphical components to it by creating child objects. However the Metafile behaves like a Bitmap object in that its children cannot be modified using ⎕WS nor can they be removed using ⎕EX. The components of a Metafile that has been initialised from a .WMF file also cannot be referenced in any way. It is therefore recommended that you use unnamed objects when you create the graphical components of a Metafile.

The following statements create an empty Metafile called MF and then draw a line and circle in it.

      'MF' ⎕WC 'Metafile'
      'MF.' ⎕WC 'Poly' (50(10 90))
      'MF.' ⎕WC 'Circle' (50 50) 30

Like the Bitmap, Icon, Font and Cursor objects, the Metafile is a resource that is not visible until it is used. This is done by setting the Picture property of another object (Form, Image, Static or SubForm) to the name of, or ref to, the Metafile object. For example, to display the Metafile MF in a Form, you could type :

      'TEST' ⎕WC 'FORM' ('Picture' 'MF')

You can also copy a Metafile object to the Windows Clipboard from where it can be pasted into another application. This is done by creating a Clipboard object and then setting its MetafileObj property to the name of the Metafile object to be exported. For example :

      'CL' ⎕WC 'Clipboard'
      'CL' ⎕WS 'MetafileObj' 'MF'

The FileWrite method may be used to save a Metafile object on a file. The following statements save the Metafile MF in a file called TEST.WMF.

      MF.File←TEST'
      MF.FileWrite

The Size property determines the granularity of the Metafile. Its default value is the size of its parent. If you intend to replay the Metafile at higher resolution, you should set Size accordingly.

The RealSize property specifies the suggested size of a Metafile in units of 0.01mm. Setting RealSize has the effect of making the Metafile placeable. Certain programs (such as Word for Windows) only support placeable metafiles.