Page 1 of 1

How to find first misspelled word from caret position

Posted: Wed Oct 19, 2005 2:42 pm
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;

Posted: Wed Oct 19, 2005 5:10 pm
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

Posted: Thu Oct 20, 2005 9:07 am
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.