EMF 文件是 Windows 下的增强图元文件, 本例用最简单的代码创建了一个 EMF 文件.
CreateEnhMetaFile( DC: HDC; {所参照的 DC, 为 0 表示参照当前的显示设备} FileName: PChar; {文件名, 为 nil 表示创建内存文件} Rect: PRect; {外接矩形(单位是 0.1 毫米), 为 nil 表示使用最小矩形} Desc: PChar {描述性的说明文本, 可为 nil} ): HDC;
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); const Path = 'C:\Temp\MyMetaFile.emf'; {CreateEnhMetaFile 创建文件时, 存在则覆盖} var MetaFileDC: HDC; {EMF 文件 DC} begin MetaFileDC := CreateEnhMetaFile(0, PChar(Path), nil, nil); {建立} Ellipse(MetaFileDC, 10, 10, 100, 60); {绘制} CloseEnhMetaFile(MetaFileDC); {关闭并保存} DeleteObject(MetaFileDC); end; end.增强图元文件的相关函数:
CloseEnhMetaFile {} CopyEnhMetaFile {} CreateEnhMetaFile {} DeleteEnhMetaFile {} EnhMetaFileProc {} EnumEnhMetaFile {} GdiComment {} GetEnhMetaFile {} GetEnhMetaFileBits {} GetEnhMetaFileDescription {} GetEnhMetaFileHeader {} GetEnhMetaFilePaletteEntries {} GetWinMetaFileBits {} PlayEnhMetaFile {} PlayEnhMetaFileRecord {} SetEnhMetaFileBits {} SetWinMetaFileBits {}