Page 1 of 1
Replace selection
Posted: Fri Dec 05, 2008 10:47 am
by dspa72
Hi,
I would like to replace a manually selected text in rvedit leaving the selection.
Actually, I select the text, use InsertText to replace the text. But, in this way, I loose the selection
Hope I was clear ....
Posted: Fri Dec 05, 2008 11:51 am
by Sergey Tkachenko
InsertText, like any other Insert*** methods introduced in TCustomRichViewEdit, deletes a selected fragment before the insertion.
So I am not sure that I understand you.
Posted: Fri Dec 05, 2008 11:57 am
by dspa72
Ok, I try to explain better my problem (sorry for my poor english).
I have this
Sports cars are performance vehicles that provide driving satisfaction
I select with the mouse the words "performance vehicles"
Sports cars are performance vehicles that provide driving satisfaction
(underline means selected)
I want to replace the selected text with "stunning autos"
so I use
rv->InsertText("stunning autos",false);
the result is
Sports cars are stunning autos that provide driving satisfaction
but i would like to have
Sports cars are stunning autos that provide driving satisfaction
Hope this is more clear
Posted: Fri Dec 05, 2008 1:34 pm
by Sergey Tkachenko
Code: Select all
int SelStart, SelLength, SelStartNew;
RVGetSelection(RichViewEdit1->TopLevelEditor, SelStart, SelLength);
if (SelLength<0)
SelStart -=SelLength;
RichViewEdit1->InsertText("aaaaaaaaaa", false);
SelStartNew = RVGetLinearCaretPos(RichViewEdit1->TopLevelEditor);
RVSetSelection(RichViewEdit1->TopLevelEditor, SelStart, SelStartNew-SelStart);