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

  1. {*****************************************************************************
  2.  *
  3.  *  Main.pas - Phoenix Mail Spell Checker MainForm
  4.  *
  5.  *  Copyright (c) 1998-99 Michael Haller
  6.  *
  7.  *  Based on VisualSpeller ActiveX Control of Visual Components, Inc.
  8.  *  Thanks to Richard Kuzsma for his tips and his demo source code
  9.  *
  10.  *  Author:     Michael Haller
  11.  *  E-mail:     michael@discountdrive.com
  12.  *  Homepage:   http://www.discountdrive.com/sunrise
  13.  *
  14.  *  This program is free software; you can redistribute it and/or
  15.  *  modify it under the terms of the GNU General Public License
  16.  *  as published by the Free Software Foundation;
  17.  *
  18.  *  This program is distributed in the hope that it will be useful,
  19.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  *  GNU General Public License for more details.
  22.  *
  23.  *  You should have received a copy of the GNU General Public License
  24.  *  along with this program; if not, write to the Free Software
  25.  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  26.  *
  27.  *----------------------------------------------------------------------------
  28.  *
  29.  *  Revision history:
  30.  *
  31.  *     DATE     REV                 DESCRIPTION
  32.  *  ----------- --- ----------------------------------------------------------
  33.  *
  34.  *****************************************************************************}
  35.  
  36. unit Main;
  37.  
  38. interface
  39.  
  40. uses
  41.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  42.   OleCtrls, vcspell3, StdCtrls;
  43.  
  44. type
  45.   TMainForm = class(TForm)
  46.     VSpell: TVSSpell;
  47.     Memo1: TMemo;
  48.     procedure FormCreate(Sender: TObject);
  49.   private
  50.     { Private declarations }
  51.   public
  52.     { Public declarations }
  53.     function CheckSpell: Boolean;
  54.   end;
  55.  
  56. var
  57.   MainForm: TMainForm;
  58.  
  59. implementation
  60.  
  61. {$R *.DFM}
  62.  
  63. function TMainForm.CheckSpell: Boolean;
  64. var
  65.   ResCode : Integer;
  66. begin
  67.   Result := False;
  68.   try
  69.     if Memo1.Text = '' then Exit;
  70.     VSpell.ClearCounts := 1;
  71.     VSpell.CheckText := Memo1.Text;
  72.     ResCode := VSpell.ResultCode;
  73.     while ResCode <> 0 do begin // loop until spellcheck complete
  74.       if ResCode > 1 then begin
  75.         // Error condition
  76.         MessageDlg('An error occurred when trying to check the spell!', mtError, [mbOK], 0);
  77.         Exit;
  78.       end;
  79.       case ResCode of
  80.         VSR_WORD_MISSPELLED, VSR_IGNORE_REPLACE: begin
  81.           VSpell.PopUpWordMisspelled := 1;
  82.           VSpell.ResultCode;
  83.         end;
  84.         VSR_CHECK_CANCELED: Break;
  85.       end;
  86.       ResCode := VSpell.ResumeCheck;
  87.     end;
  88.     Memo1.Text := VSpell.Text;
  89.     Result := True;
  90.   except
  91.     MessageDlg('An error occurred when trying to check the spell!', mtError, [mbOK], 0);
  92.   end;
  93. end;
  94.  
  95. procedure TMainForm.FormCreate(Sender: TObject);
  96. begin
  97.   Caption := Application.Title;
  98.   Icon := Application.Icon;
  99.   Width := 0;
  100.   Height := 0;
  101.   Left := -100;
  102.   Top := -100;
  103.   VSpell.DialogBgColor := ColorToRGB(clBtnFace);
  104. end;
  105.  
  106. end.
  107.