Bug in RVGetTextLength function

General TRichView support forum. Please post your questions here
Post Reply
JPR
Posts: 35
Joined: Fri Apr 14, 2006 7:27 am

Bug in RVGetTextLength function

Post 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
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

You need to call Format after Clear.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
Post Reply