home *** CD-ROM | disk | FTP | other *** search
/ Freelog 11 / Freelog011.iso / BestOf / PhoenixMail / Source / phoenix / FMSpellCheck.pas < prev    next >
Pascal/Delphi Source File  |  1999-02-05  |  3KB  |  113 lines

  1. {*****************************************************************************
  2.  *
  3.  *  FMSpellCheck.pas - Check the spell of e-mails  (12-September-1998)
  4.  *
  5.  *  Copyright (c) 1998-99 Michael Haller
  6.  *
  7.  *  Author:     Michael Haller
  8.  *  E-mail:     michael@discountdrive.com
  9.  *  Homepage:   http://www.discountdrive.com/sunrise
  10.  *
  11.  *  This program is free software; you can redistribute it and/or
  12.  *  modify it under the terms of the GNU General Public License
  13.  *  as published by the Free Software Foundation;
  14.  *
  15.  *  This program is distributed in the hope that it will be useful,
  16.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  *  GNU General Public License for more details.
  19.  *
  20.  *  You should have received a copy of the GNU General Public License
  21.  *  along with this program; if not, write to the Free Software
  22.  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  23.  *
  24.  *----------------------------------------------------------------------------
  25.  *
  26.  *  Revision history:
  27.  *
  28.  *     DATE     REV                 DESCRIPTION
  29.  *  ----------- --- ----------------------------------------------------------
  30.  *
  31.  *****************************************************************************}
  32.  
  33. unit FMSpellCheck;
  34.  
  35. interface
  36.  
  37. uses
  38.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  39.   StdCtrls, ExtCtrls, PXStuff, ShellAPI;
  40.  
  41. type
  42.   TSpellCheckForm = class(TForm)
  43.     Panel1: TPanel;
  44.     Timer1: TTimer;
  45.     Label1: TLabel;
  46.     Image1: TImage;
  47.     procedure FormCreate(Sender: TObject);
  48.     procedure Timer1Timer(Sender: TObject);
  49.     procedure FormShow(Sender: TObject);
  50.   private
  51.     { Private declarations }
  52.     procedure WndProc(var Message: TMessage); override;
  53.   public
  54.     { Public declarations }
  55.     Ready: Boolean;
  56.     procedure SpellCheck;
  57.   end;
  58.  
  59. var
  60.   SpellCheckForm: TSpellCheckForm;
  61.  
  62. implementation
  63.  
  64. {$R *.DFM}
  65.  
  66. uses
  67.   Main;
  68.  
  69. procedure TSpellCheckForm.SpellCheck;
  70. begin
  71.   Ready := False;
  72.   MainForm.RichEdit1.Lines.SaveToFile(sTempSpellCheckFile);
  73.   ShellExecute(Handle, 'open', PChar(sSpellCheckerFile), PChar('"'+sTempSpellCheckFile+'" '+IntToStr(Handle)), PChar(ExtractFilePath(sTempSpellCheckFile)), SW_SHOWNORMAL);
  74.   repeat
  75.     Application.HandleMessage;
  76.   until Ready;
  77.   if FileExists(sTempSpellCheckFile) then
  78.     MainForm.RichEdit1.Lines.LoadFromFile(sTempSpellCheckFile);
  79. end;
  80.  
  81. procedure TSpellCheckForm.WndProc(var Message: TMessage);
  82. begin
  83.   if Message.Msg = WM_SPELLCHECKFINISHED then begin
  84.     Ready := True;
  85.   end else
  86.     inherited WndProc(Message);
  87. end;
  88.  
  89. procedure TSpellCheckForm.FormCreate(Sender: TObject);
  90. begin
  91.   ClientWidth := Panel1.Width;
  92.   ClientHeight := Panel1.Height;
  93.   if bOfficeFonts then Font.Name := sOfficeFontName;
  94. end;
  95.  
  96. procedure TSpellCheckForm.Timer1Timer(Sender: TObject);
  97. begin
  98.   if not Visible then Exit;
  99.   Timer1.Enabled := False;
  100.   try
  101.     SpellCheck;
  102.   except end;
  103.   DeleteFile(sTempSpellCheckFile);
  104.   Close;
  105. end;
  106.  
  107. procedure TSpellCheckForm.FormShow(Sender: TObject);
  108. begin
  109.   Timer1.Enabled := True;
  110. end;
  111.  
  112. end.
  113.