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

  1. unit Template_Chart;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Base, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, ActnList,
  8.   TeeChartActions;
  9.  
  10. type
  11.   TTemplateChart = class(TBaseForm)
  12.     TemplateChart: TChart;
  13.     Button1: TButton;
  14.     Button2: TButton;
  15.     ActionList1: TActionList;
  16.     ChartActionEdit1: TChartActionEdit;
  17.     Splitter1: TSplitter;
  18.     procedure Button2Click(Sender: TObject);
  19.     procedure FormCreate(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. implementation
  27.  
  28. {$R *.DFM}
  29. Uses TeeStore;
  30.  
  31. procedure TTemplateChart.Button2Click(Sender: TObject);
  32. var tmp : TMemoryStream;
  33. begin
  34.   { 1) Save the template into a Stream... }
  35.   tmp:=TMemoryStream.Create;
  36.   try
  37.     { save only Chart and Series formatting, not data }
  38.     SaveChartToStream(TemplateChart,tmp,False);
  39.  
  40.     { 2) Load the template... }
  41.     LoadChartFromStream(TCustomChart(Chart1),tmp);
  42.  
  43.     { restore the chart alignment (in this example) }
  44.     Chart1.Align:=alClient;
  45.  
  46.     { repaint the Chart }
  47.     Chart1.Repaint;
  48.   finally
  49.     { remove the stream, it's no longer necessary... }
  50.     tmp.Free;
  51.   end;
  52. end;
  53.  
  54. procedure TTemplateChart.FormCreate(Sender: TObject);
  55. begin
  56.   inherited;
  57.   { global variable, to add random points at runtime }
  58.   TeeRandomAtRunTime:=True;
  59. end;
  60.  
  61. initialization
  62.   RegisterClass(TTemplateChart);
  63. end.
  64.