Page 1 of 1

Search and Replace problem

Posted: Fri Nov 04, 2011 1:16 pm
by rafakwolf
Hello..

i am trying to search and replace texts...but no success..

using this code :

Code: Select all

procedure SearchAndReplace(rve: TCustomRichViewEdit; old, new: String);
begin
  with rve do
  begin
    SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));

    while SearchText(old, [rvseoDown,rvseoWholeWord]) do
      InsertText(new);
  end;
end;
in the "chat-form" following you can see the problem:

Image

i'm calling the procedure, after text inserted of course...

something wrong ?

thanks alot.[/img]

Re: Search and Replace problem

Posted: Fri Nov 04, 2011 1:20 pm
by rafakwolf
rafakwolf wrote:Hello..

i am trying to search and replace texts...but no success..

using this code :

Code: Select all

procedure SearchAndReplace(rve: TCustomRichViewEdit; old, new: String);
begin
  with rve do
  begin
    SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));

    while SearchText(old, [rvseoDown,rvseoWholeWord]) do
      InsertText(new);
  end;
end;
in the "chat-form" following you can see the problem:

Image

i'm calling the procedure, after text inserted of course...

something wrong ?

thanks alot.
OBS.:

calling this way

Code: Select all

  add formatted text
...
...
...
SerachAndReplace(MyRvEdit,'<USER>','THEÒS INFORMÁTICA LTDA');

Posted: Fri Nov 04, 2011 7:12 pm
by Sergey Tkachenko
I read in the private message that your document is read-only.
Yes, all editing methods are blocked in read-only mode, so InsertText does not work.

You can temporary assign ReadOnly=False before executing this code and then restore it back.
But the best solution would be using non-editing methods.