home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / TeeChartPro / TeeChart5Delphi5Eval.exe / %MAINDIR% / Examples / Features / Export_Metafile.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-10  |  2.2 KB  |  83 lines

  1. unit Export_Metafile;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Teengine, Series, ExtCtrls, Chart, StdCtrls,
  8.   Buttons, TeeProcs;
  9.  
  10. type
  11.   TMetafileForm = class(TForm)
  12.     Chart1: TChart;
  13.     Image1: TImage;
  14.     BarSeries1: TBarSeries;
  15.     Panel1: TPanel;
  16.     Panel2: TPanel;
  17.     SaveDialog1: TSaveDialog;
  18.     BitBtn2: TBitBtn;
  19.     BitBtn3: TBitBtn;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure BitBtn3Click(Sender: TObject);
  22.     procedure BitBtn2Click(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32. uses Clipbrd;
  33.  
  34. procedure TMetafileForm.FormCreate(Sender: TObject);
  35. begin
  36.   BarSeries1.FillSampleValues(8);  { <-- some sample random bars }
  37. end;
  38.  
  39. { This code copies Chart contents onto Windows Clipboard in Metafile Format }
  40. procedure TMetafileForm.BitBtn3Click(Sender: TObject);
  41. begin
  42. {    TeeClipWhenMetafiling:=True; {  <--- FORCE CLIPPING WITH METAFILES }
  43. {    CLIPPING WORKS FINE BUT DO NOT ALLOW MOVEABLE OR RESIZEABLE METAFILES }
  44.  
  45.   Chart1.CopyToClipboardMetafile(True);  { <--- Enhanced Metafile = True }
  46.  
  47.   ShowMessage('Chart1 is now at Windows Clipboard in Metafile format.'+#13+
  48.               'and will now be pasted HERE !');
  49. { Now PASTE! }
  50.   Image1.Picture.Assign(ClipBoard);
  51.   Image1.Refresh;
  52. end;
  53.  
  54. { This button asks a filename and saves the Chart }
  55. procedure TMetafileForm.BitBtn2Click(Sender: TObject);
  56. begin
  57.   if SaveDialog1.Execute then  { <-- ask for a filename first }
  58.   begin
  59.    { SAVE IT !! }
  60.  
  61. {    CLIPPING WORKS FINE BUT DO NOT ALLOW MOVEABLE OR RESIZEABLE METAFILES }
  62. {    TO FORCE CLIPPING WITH METAFILES UNCOMMENT THIS LINE: }
  63. {    TeeClipWhenMetafiling:=True;  }
  64.  
  65.     Chart1.SaveToMetafile(SaveDialog1.FileName);
  66.  
  67.    { THIS METHOD CAN BE USED TOO: }
  68. (*
  69.       Chart1.SaveToMetafileRect( SaveDialog1.FileName,
  70.       Rect( 0,0, round(21{cm}*37.8), round(10{cm}*37.8)));
  71. *)
  72. {   ( this equals to 96 * 21 / 2.54 , 96 * 10 /2.54 )   }
  73.  
  74.     { now it's loaded HERE ! }
  75.     Image1.Picture.LoadFromFile(SaveDialog1.FileName);
  76.     Image1.Refresh;
  77.   end;
  78. end;
  79.  
  80. initialization
  81.   RegisterClass(TMetafileForm);
  82. end.
  83.