Dear all,
I'd like to allow copy/paste from graphs drawn with my application, based on
EvsSimpleGraph package, towards externals applications.
May be I'm missing something, but with the following demo code,
after execution, if I paste on Windows Paint, I have the wrong result showed
in the second screenshot...
Does anyone have any suggestions? Thanks in advance.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Clipbrd, USimpleGraph;
type
TForm1 = class(TForm)
Graph : TEvsSimpleGraph;
procedure FormShow(Sender: TObject);
private
procedure CopyToClipBoard(aGraph : TEvsSimpleGraph; SrcRect : TRect);
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.FormShow(Sender: TObject);
begin
Graph:=TEvsSimpleGraph.Create(Self);
Graph.Align:=alClient;
Graph.Parent:=Self;
Graph.InsertNode(Rect(50,50,100,100));
CopyToClipBoard(Graph,Rect(0,0,110,110));
end;
procedure TForm1.CopyToClipBoard(aGraph : TEvsSimpleGraph; SrcRect : TRect);
var
BmpSrc,BmpDst : TBitmap;
DstRect : TRect;
begin
BmpSrc:=TBitmap.Create;
BmpDst:=TBitmap.Create;
aGraph.CopyToGraphic(BmpSrc);
DstRect:=Rect(0,0,SrcRect.Width,SrcRect.Height);
BmpDst.Width:=DstRect.Width;
BmpDst.Height:=DstRect.Height;
BmpDst.Canvas.CopyRect(DstRect,BmpSrc.Canvas,SrcRect);
Clipboard.Assign(BmpDst);
BmpSrc.Free;
BmpDst.Free;
end;
end.