Skip to content

Instantly share code, notes, and snippets.

@UweRaabe
Last active April 7, 2016 17:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UweRaabe/92021a7c1566b84ba7427a7a0da28fbd to your computer and use it in GitHub Desktop.
Save UweRaabe/92021a7c1566b84ba7427a7a0da28fbd to your computer and use it in GitHub Desktop.
Screenshot to Metafile
unit Unit77;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Actions, Vcl.ActnList;
type
TForm77 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form77: TForm77;
implementation
{$R *.dfm}
procedure TForm77.Button1Click(Sender: TObject);
var
cnv: TMetafileCanvas;
emf: TMetafile;
notused: HWND;
begin
emf := TMetafile.Create;
try
emf.SetSize(ClientWidth, ClientHeight);
cnv := TMetafileCanvas.Create(emf, GetDeviceContext(notused));
try
Self.PaintTo(cnv, 0, 0);
finally
cnv.Free;
end;
emf.SaveToFile('c:\temp\Test.emf');
finally
emf.Free;
end;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment