Replace word with text from another DBRichViewEdit
Posted: Mon Mar 14, 2011 2:16 am
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.
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.
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;
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.