Page 1 of 1

Bug in RVGetTextLength function

Posted: Fri Jun 30, 2006 7:48 am
by JPR
Hello everybody,

I have a bug (I think in RVGetTextLength function)

If I do that, DELPHI send me Out of limit (-1)

MyRichViewEdit.Clear;
ShowMessage(IntToStr(RVGetTextLength(MyRichViewEdit)));

Have youa solution for that Sergey ?

Thank

JP

Posted: Fri Jun 30, 2006 11:56 am
by Michel
You need to call Format after Clear.

Posted: Sun Jul 02, 2006 4:27 pm
by Sergey Tkachenko
Well, yes, calling Format saves the situation for TRichViewEdit (because it adds one empty text item).
But not for TRichView, so it may be really considered as a bug.
Fix: open RVLinear.pas, change RVGetTextLength:

Code: Select all

function RVGetTextLength(rv: TCustomRichView): Integer;
begin
  Result := 0;
  if rv.ItemCount=0 then
    exit;
  RichViewToLinear(rv, rv.RVData, rv.RVData, rv.ItemCount-1,
    rv.GetOffsAfterItem(rv.ItemCount-1), Result);
  if Result>0 then
    dec(Result);
end;