Board index » delphi » RichEdit doesn't refresh after a search and replace

RichEdit doesn't refresh after a search and replace

Hello!

I have written a small editor which aims to convert ASCII 8-bit chars to
the HTML char code and in the other direction. I use a RichEdit window
with PlainText:=true, in order to overcome the 32K limit of TMemo and to
save HTML text files.

When I try to convert a text without accentuated chars, the RichEdit
Window gets blank and I have to resize or scroll the window to refresh.
I've already try to add a Paint command, a SetFocus, to set
RichEdit.Enabled to True and RichEdit.Visible to true.

The procedure is:
        TempText:= TForm1(ActiveMDIChild).RichEdit1.Text;
        ...
        for i:=1 to MAXCONV do
          begin
            ProgressBar1.Stepit;
            while pos(TabConv[i,2],TempText) >0 do
            begin
                 Posi := pos(TabConv[i,2],TempText);
                 delete (TempText,Posi,Length(TabConv[i,2]));
                 insert (TabConv[i,1],TempText,Posi)
            end;
          end; (*for*)
        ...
        with  TForm1(ActiveMDIChild).RichEdit1 do
          begin
               Text := TempText;
               SelStart:=0;
               Visible:=true;
               Enabled:=true;
          end;

Other problem: when the file is very huge, the RichEdit window doesn't
allow the user to edit the text, while modification made by the programm
are allowed, such as "search and replace".

Any idea?

 

Re:RichEdit doesn't refresh after a search and replace


Quote
Sebastien L'haire wrote in message <357D3CDA.20C95...@seinf.unige.ch>...
>When I try to convert a text without accentuated chars, the RichEdit
>Window gets blank and I have to resize or scroll the window to refresh.
>I've already try to add a Paint command, a SetFocus, to set
>RichEdit.Enabled to True and RichEdit.Visible to true.

Have you tried a .invalidate?  In anycase it probably wont update until
after the search and replace has finished.

Quote
>The procedure is:
> TempText:= TForm1(ActiveMDIChild).RichEdit1.Text;
> ...
> for i:=1 to MAXCONV do
>          begin
>            ProgressBar1.Stepit;
>            while pos(TabConv[i,2],TempText) >0 do
>            begin
>                 Posi := pos(TabConv[i,2],TempText);
>                 delete (TempText,Posi,Length(TabConv[i,2]));
>                 insert (TabConv[i,1],TempText,Posi)
>            end;
>          end; (*for*)
> ...
> with  TForm1(ActiveMDIChild).RichEdit1 do
>          begin
>               Text := TempText;
>               SelStart:=0;
>               Visible:=true;
>               Enabled:=true;
>          end;

>Other problem: when the file is very huge, the RichEdit window doesn't
>allow the user to edit the text, while modification made by the programm
>are allowed, such as "search and replace".

Its you that wont let them edit!  You need to do an
Application.ProcessMessages or some such lark in your loop, but this is
still a bad idea, because you will be editing the text behind their back,
perhaps the line they are trying to change.  Maybe they will to a ^V to
paste a load of text, or ^X to cut some text, causing you to miss out some
of your search and replace.

And if you do do an Application.ProcessMessages, beware of nested calls to
your form event handlers.

Sam

Other Threads