Copy metafiles to clipboard? lazarus / 55-TAChart ---------------------------------------------------------------------- ironphil · 2014-09-30 02:04 Now that the metafile format is right, would that be difficult to have something like the existing procedure "Chart1.CopyToClipboardBitmap" but for metafiles? Something like "Chart1.CopyToClipboardMetafile". Even if it is specific to Windows. ---------------------------------------------------------------------- wp · 2014-09-30 18:35 Metafile are not supported offcially by Lazarus/FPC. What we have in in TAChart in a windows-only workaround for this package without full integration in the graphics infrastructure. On the other hand from what I saw with the other image formats today, I get the feeling that it should be possible to add clipboard support for meta files, at least for windows. Give me some time and some quite moments to understand how the clipboard formats work. ---------------------------------------------------------------------- wp · 2014-10-01 10:27 I found a solution - as always when you know it, it was not that difficult. Before adding it to trunk I'd ask you to test it. Please copy the attached TADrawerCanvas unit over the original one (it is in (lazarus)\components\tachart); you may want to make a copy of the original one in case you want to switch back again. Recompile the TAChart package. That should be all. In order to copy a chart to the clipboard as a metafile use the same code as for saving to file, but leave the file name empty: Code: [Select]procedure TForm1.btnCopyToClipboardClick(Sender: TObject); begin   with Chart1 do     Draw(TWindowsMetafileDrawer.Create(''), Rect(0, 0, Width, Height));     // Setting the file name to an empty string results in copying the chart to     // the clipboard. end; Not really straightforward, but I cannot add a CopyToClipboardMetafile method (like CopyToClipboardBitmap) to TChart because the wmf stuff is in a separate package (for good reasons...) Note that this code runs only under Windows. ---------------------------------------------------------------------- ironphil · 2014-10-01 20:31 It looks perfect to me. I tested it with my own project just like you instructed and it just worked as expected. Many thanks. ---------------------------------------------------------------------- wp · 2014-10-01 21:31 It's in trunk, r48396. The wmfdemo contains a button "Copy to clipboard" now. See also the wiki http://wiki.lazarus.freepascal.org/TAChart_Demos#wmf ---------------------------------------------------------------------- wp · 2014-10-02 15:01 Quote I cannot add a CopyToClipboardMetafile method (like CopyToClipboardBitmap) to TChart because the wmf stuff is in a separate packageBut I did not think of the magnificent class helpers! Today I added "CopyToClipboardMetaFile" and "SaveAsMethod" to TChart by using a class helper implemented in the wmf unit (--> r46404). These identifiers are much easier to remember. Just have a look at the wmfdemo which shows the new syntax now: Code: [Select]  // copy a chart to clipboard as a windows metafile   Chart.CopyToClipboardMetafile;   // save a chart to a windows metafile   Chart.SaveAsWMF('c:\temp\chart.wmf');