home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / EXTENDED / UTWOCLIP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  2.0 KB  |  80 lines

  1. unit utwoclip;
  2. {$I teedefs.inc}
  3.  
  4. interface
  5.  
  6. { This example merges two Charts into a single metafile object,
  7.   then copies the metafile to clipboard.
  8.  
  9.   FOR Delphi 2.0 and 3.0 ONLY  ( 32-bit Windows 95 or NT )
  10. }
  11. uses
  12.   Wintypes, WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   TeEngine, Series, StdCtrls, Buttons, ExtCtrls, TeeProcs, Chart;
  14.  
  15. type
  16.   TClipboardTwoForm = class(TForm)
  17.     Chart1: TChart;
  18.     Chart2: TChart;
  19.     BitBtn1: TBitBtn;
  20.     Series1: TBarSeries;
  21.     Button1: TButton;
  22.     Series2: TAreaSeries;
  23.     procedure BitBtn1Click(Sender: TObject);
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure Button1Click(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   ClipboardTwoForm: TClipboardTwoForm;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38. Uses Clipbrd;
  39.  
  40. procedure TClipboardTwoForm.BitBtn1Click(Sender: TObject);
  41. Var Meta      : TMetafile;
  42.     {$IFNDEF D1}
  43.     tmpCanvas : TMetafileCanvas; { <-- for 32-bit only ! }
  44.     {$ENDIF}
  45. begin
  46.   Meta:=TMetafile.Create;  { create a temporary metafile image }
  47.   try
  48.     Meta.Width:=200;        { set metafile dimensions }
  49.     Meta.Height:=210;
  50.     {$IFNDEF D1}
  51.     Meta.Enhanced:=True;
  52.     tmpCanvas:=TMetafileCanvas.Create(Meta,0);  { create a temporary canvas }
  53.     try
  54.       { draw first chart }
  55.       Chart1.DrawToMetaCanvas(tmpCanvas,Rect(0,0,200,100));
  56.       { draw second chart }
  57.       Chart2.DrawToMetaCanvas(tmpCanvas,Rect(0,110,200,210));
  58.     finally
  59.       tmpCanvas.Free;       { destroy the temporary canvas }
  60.     end;
  61.     {$ENDIF}
  62.     Clipboard.Assign(Meta);  { copy the metafile to clipboard }
  63.   finally
  64.     Meta.Free;  { destroy the temporary metafile }
  65.   end;
  66. end;
  67.  
  68. procedure TClipboardTwoForm.FormCreate(Sender: TObject);
  69. begin
  70.   Series1.FillSampleValues(5);
  71.   Series2.FillSampleValues(5);
  72. end;
  73.  
  74. procedure TClipboardTwoForm.Button1Click(Sender: TObject);
  75. begin
  76.   Close;
  77. end;
  78.  
  79. end.
  80.