• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 759
  • Last Modified:

How to create a metafile in Delphi 3 ?

How to draw some boxes and lines to a tmetafile object and save as a windows enhances metafile format?
0
jlislo
Asked:
jlislo
  • 2
1 Solution
 
StevenBCommented:
Hi Jlislo,

  The procedure is to create the metafile, then create a metafilecanvas. when you free the metafilecanvas, whatever you've drawn on it becomes the contents of the metafile. Saving the file is as simple as calling SaveToFile.

  Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  AMetafile : TMetafile;
  AMetafileCanvas : TMetafileCanvas;
begin
  AMetaFile := TMetafile.Create;

  AMetafileCanvas := TMetafileCanvas.Create(AMetaFile, 0);
  try
    AMetaFileCanvas.LineTo(100,100);
    // Draw the imagea on the MetafileCanvas Here
  finally
    AMetafileCanvas.Free;
  end;

  AMetafile.SaveToFile('FileName');
  AMetaFile.Free;
end;

  Steven.
0
 
jlisloAuthor Commented:
What is the different between enhance metafile and a normal metafile in program wise?
0
 
StevenBCommented:
 The difference between the standard and enhanced metafiles behaviour is pretty small. TMetafile has an Enhanced property which you can set to true to force EMF format. Enhanced metafiles are the new standard and should be used for most purposes, nornal metafiles are provided for back compatibility only. Delphi actually converts normal metafiles (WMF) into enhanced metafiles (EMF) for its own purposes anyway.

  Steven.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now