TNGEnhMetafileFormat

<< Click to Display Table of Contents >>

Navigation:  Data Formats >

TNGEnhMetafileFormat

Previous pageReturn to chapter overviewNext page

TNGEnhMetafileFormat class implements standard CF_ENHMETAFILE data format and allows to drag/receive Windows GDI metafiles. NG Drag&Drop use TMetafile standard Delphi type for working with metafile data.

 

The class declares two methods: Data and Ref. Data method can be used to drag metafile data at the source side, while Ref method can be used to receive metafiles at the target side. NG Drag&Drop declares special type alias CF.ENHMETAFILE to make user's code more readable:

 

NGDropSource.Add(CF.ENHMETAFILE.Data(m))
            .Execute;
 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  m: TMetafile;
begin
  m := TMetafile.Create;
  try
    if C.Accept(CF.ENHMETAFILE.Ref(m)) then
      ShowMetafile(m);
  finally
    m.Free;
  end;
end);

 

Moreover, special methods are declared for working with bitmap data, which can simplify code even more:

 

NGDropSource.AddEnhMetafile(m)
            .Execute;
 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  m: TMetafile;
begin
  m := TMetafile.Create;
  try
    if C.AcceptEnhMetafile(m) then
      ShowMetafile(m);
  finally
    m.Free;
  end;
end);