counter OneDomain, Inc. - Other Products
 
WPTools Source for EDSSpell

 
 
Implementing auto-highlighting and the spell popup menu using WPTools is easy... Attach the following code to the specified WPTools and EDSSpell events and you're done!

 
 
Implement Auto-Underlining of mis-spelled words (TWPRichText.OnSpellCheckWord event):

		procedure TWordPadForm.WPRichText1SpellCheckWord(Sender: TObject;
		  word: String; var res: TSpellCheckResult; var hypen: TSpellCheckHyphen);
		begin
		  if not WPSpellDlg1.InDictionary(Word) then
		    Res := [spMisSpelled];
		end;
		
		


Implement SpellPopupMenu to correct mis-spelled words (TWPRichText.OnMouseDown event):

		procedure TWordPadForm.WPRichText1MouseDown(Sender: TObject;
		  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
		begin
		  if Button = mbRight then
		    SpellPopupMenu1.SpellPopup(WPRichText1, Button, X, Y);
		end;
		


Implement EDSSpell dialog (TWPRichText.StartSpellCheck event):

		procedure TWordPadForm.WPRichText1StartSpellCheck(Sender: TObject);
		begin
		  WPSpellDlg1.SpellCheck(WPRichText1);
		end;
		
		


Implement AutoCorrect (TWPRichText.AfterCompletedWord event):

		procedure TWordPadForm.WPRichText1AfterCompleteWordEvent(Sender: TObject;
		  var lastchar:	Char);
		begin
		 WPSpellDlg1.AutoCheck (WPRichText1, TRUE, Ord (LastChar));
		end;
		
		


Implement EDSThesaurus using EDSSpell:

		procedure TWordPadForm.Thesaurus1Click(Sender: TObject);
		var
		  CurrentWord: String;
		begin
		  {make sure EDSSpell is initialized properly}
		  WPSpellDlg1.OpenDictionary;
		  WPSpellDlg1.InitBufferMgr (WPRichText1);
		
		  {get the current word and highlight it}
		  CurrentWord := WPSpellDlg1.BufferMgr.GetCurrentWord (WPRichText1);
		  WPSpellDlg1.BufferMgr.SetSelectedText;
		
		  {lookup the word and replace on Copy}
		  WordWeb1.LookupWord := CurrentWord;
		  if WordWeb1.Execute then
		  begin
		    WPSpellDlg1.BufferMgr.ReplaceWord (WordWeb1.SelectedText);
		    WPSpellDlg1.BufferMgr.UnSelectText;
		  end;  { if... }
		end;