Board index » delphi » TRichEdit - temporary loss of line.count?

TRichEdit - temporary loss of line.count?

I have a program which is scanning through lines of a richedit and setting
color attributes.  Occasionally it loses track of number of lines just
after calling SendMessage with EM_SETCHARFORMAT.  For example, suppose
there are 200 lines, I execute the code:

  SelStart := <beginning of line 50>
  SelLength := <length of line 50>
  SelAttributes.color := clRed;
  <control now shows < 200 lines in both lines.count and if I do a direct
SendMessage for line count>

If I change the attribute setting line (SelAttributes.color := clRed) to

   SelText := '*** ' + SelText + ' ***'

Then everything works fine.  Similar problems with setting any other text
attributes.  

Any ideas?  Thanks in advance,

Jim

 

Re:TRichEdit - temporary loss of line.count?


Problems solved!!!  All I had to do was focus the TRichEdit with SetFocus
before manipulating it and it stopped losing track of the lines!

Sounds like a Win32 bug to me!  Hope this helps someone else.

Jim

Jim Hollenberg <jholl...@nyh.med.cornell.edu> wrote in article
<01bd712e$e0a47330$e9ddfb8c@ht4nt8888>...

Quote
> I have a program which is scanning through lines of a richedit and
setting
> color attributes.  Occasionally it loses track of number of lines just
> after calling SendMessage with EM_SETCHARFORMAT.  For example, suppose
> there are 200 lines, I execute the code:

>   SelStart := <beginning of line 50>
>   SelLength := <length of line 50>
>   SelAttributes.color := clRed;
>   <control now shows < 200 lines in both lines.count and if I do a direct
> SendMessage for line count>

> If I change the attribute setting line (SelAttributes.color := clRed) to

>    SelText := '*** ' + SelText + ' ***'

> Then everything works fine.  Similar problems with setting any other text
> attributes individually.  

> Any ideas?  Thanks in advance,

> Jim

Other Threads