用 GDI 操作 EMF 文件[2]: PlayEnhMetaFile、DeleteEnhMetaFile

创建 EMF 文件, 并同时绘制在窗体.

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';

var

  MetaFileDC: HDC;         {EMF 画布句柄}

  HMetaFile: HENHMETAFILE; {EMF 文件句柄}

begin

  MetaFileDC := CreateEnhMetaFile(0, PChar(Path), nil, nil);

  Ellipse(MetaFileDC, 10, 10, 100, 60);

  HMetaFile := CloseEnhMetaFile(MetaFileDC);



  {在窗体上按原始大小绘制 EMF}

  PlayEnhMetaFile(Canvas.Handle, HMetaFile, Rect(10,10,100,60));



  DeleteObject(MetaFileDC);

  DeleteEnhMetaFile(HMetaFile);

end;



end.


 
   

你可能感兴趣的:(delete)