Page 1 of 1

Replace word with text from another DBRichViewEdit

Posted: Mon Mar 14, 2011 2:16 am
by agent86
I have written my own AutoText/AutoCorrect because I need to enter and retrieve paragraphs of formatted text. I use the following to append the text to another DBRichView.

Code: Select all

procedure TReportWriterMainForm.AddReplacementText ;
var Stream: TMemoryStream;
begin
   Stream := TMemoryStream.Create;
   ReplacementTextDBRichViewEdit.SaveRVFToStream(Stream, False);
   Stream.Position := 0;
   rve.AppendRVFFromStream(Stream, -1 );
   Stream.Free;
   rve.Format;
end;
The problem of course is that the target word in the sentence needs to be replaced with the text. I have studied the AutoCorrect function but don't see how to overwrite the "word" that is to be replaced.

How do I find the previous word in a sentence related to my current cursor position? Of course it could be the first word in the sentence or in the middle of a sentence that needs to be replaced. It won't always be the last word.

I have done all the programming to look up the replacement text. The only problem I have left is finding the word before my cursor and replacing the word with my replacment text which is "stored" in a DBRichView.

Posted: Thu Mar 17, 2011 7:23 pm
by Sergey Tkachenko
Look in RichViewActions.pas, RVA_Addict3AutoCorrect (this function makes autocorrection using Addict3/4.
This functions selects the word to the left of the caret position (using SetSelectionBounds), and inserts a new text that replaces the selection,