How to find first misspelled word from caret position
Posted: Wed Oct 19, 2005 2:42 pm
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;
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;