home *** CD-ROM | disk | FTP | other *** search
/ PC Expert 29 / Pce29cd.iso / RUNIMAGE / DELPHI40 / DEMOS / TEECHART / UMETAFIL.PAS < prev    next >
Pascal/Delphi Source File  |  1998-06-16  |  3KB  |  88 lines

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