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

  1. unit Export_Email;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Base, TeEngine, Series, ImaPoint, StdCtrls, ExtCtrls, TeeProcs, Chart;
  8.  
  9. type
  10.   TExportEmailForm = class(TBaseForm)
  11.     Button1: TButton;
  12.     Series1: TDeltaPointSeries;
  13.     Button2: TButton;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure FormCreate(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. implementation
  24.  
  25. {$R *.dfm}
  26.  
  27. Uses TeExport, TeeJPEG, TeeConst;
  28.  
  29. procedure TExportEmailForm.Button1Click(Sender: TObject);
  30. begin
  31.   TeeExport(Self,Chart1);
  32. end;
  33.  
  34. procedure TExportEmailForm.FormCreate(Sender: TObject);
  35. begin
  36.   inherited;
  37.   Series1.FillSampleValues(20);
  38. end;
  39.  
  40. procedure TExportEmailForm.Button2Click(Sender: TObject);
  41. type TPathName=Array[0..MAX_PATH] of Char;
  42. var tmpPath,
  43.     tmpName : TPathName;
  44. begin
  45.   { obtain the "temp" folder path... }
  46.   if GetTempPath(MAX_PATH,tmpPath)=0 then
  47.      Raise Exception.Create(TeeMsg_CanNotFindTempPath);
  48.  
  49.   { set the filename to "\temp\teechart.jpg" }
  50.   StrPCopy(tmpName,StrPas(tmpPath)+'\TeeChart.jpg');
  51.  
  52.   { create the JPEG chart... }
  53.   With TJPEGExportFormat.Create do
  54.   try
  55.     Panel:=Chart1;
  56.     SaveToFile(tmpName);
  57.   finally
  58.     Free;
  59.   end;
  60.  
  61.   { email the jpeg chart... }
  62.   TeeEmailFile(tmpName);
  63.  
  64.   { delete the temporary jpeg file... }
  65.   DeleteFile(tmpName);
  66. end;
  67.  
  68. initialization
  69.   RegisterClass(TExportEmailForm);
  70. end.
  71.