How to find first misspelled word from caret position

General TRichView support forum. Please post your questions here
Post Reply
markkuin2
Posts: 10
Joined: Tue Sep 06, 2005 9:57 am

How to find first misspelled word from caret position

Post by markkuin2 »

I'm trying to find the first misspelled word from the caret position, but my code breaks when there are tables which contain text. (the spelling errors in the tables won't be found) Is there a way to walk through all the text in the table cells? This is my code:

procedure TForm1.FindError;
var
i, j, SI, SIO, EI, EIO, TxtLen, k, AStyleNo : Integer;
AStr, AWoord : String;
begin
frmSpelling.Show;
RVEMain.GetSelectionBounds(SI, SIO, EI, EIO, True);

ClearEvents;
try
if (SI >= 0) and (SIO >= 0) then
begin
for i := SI to RVEMain.ItemCount - 1 do
begin
AStr := RVEMain.GetItemTextA(i);

TxtLen := Length(AStr);
if (i = SI) then
k := SIO
else
k := 1;

for j := k to TxtLen do
begin
RVEMain.SetSelectionBounds(i, j, i, j);
Application.ProcessMessages;
if RVEMAin.GetCurrentMisspelling(True, AWoord, AStyleNo) then
begin
frmSpelling.Woord := AWoord;
Exit;
end;
end;

end;
end;
finally
AddEvents;
end;

frmSpelling.Hide;
end;
Sergey Tkachenko
Site Admin
Posts: 17254
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What exactly do you want to do?
Do you want to move caret to all possible positions in text and check if they are misspelled using GetCurrentMisspelling?
To move caret inside table, you need a recursive procedure, like it's shown in http://www.trichview.com/forums/viewtopic.php?t=46 (do not forget to call Edit before SetSelectionBounds).

But I do not recommend to use this method. It's much better to use standard (non-livespell) interface for spellcheckers for this task.
For Addict 3, it is implemented here:
http://www.trichview.com/resources/adrv3/adrv3.zip
For other spellcheckers, it's here:
http://www.trichview.com/resources/spell/rvspell.zip
markkuin2
Posts: 10
Joined: Tue Sep 06, 2005 9:57 am

Post by markkuin2 »

Thanks Sergey, I needed the standard interface for spellcheckers, so I changed one of the interfaces to work with my own list of words.
Post Reply