trichview.com

trichview.support




Re: Dummy question


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/04/2002 18:34:50


> I use a RichView for a log display. I do many AddNL (with different

colors)

> per line.

>

> How can I delete the first 20 lines of text (not items !) for example ?


You can calculate which item ends last line (more exactly - last paragraph,

because lines depends on word wrapping).


Something like this:


procedure DeleteFirstNParas(rv: TCustomRichView; N: Integer);

var i: Integer;

begin

  i := 0;

  while (i<rv.ItemCount) do begin

    if rv.IsParaStart(i) then begin

      dec(N);

      if N<0 then begin

        dec(i);

        break;

      end;

    end;

    inc(i);

  end;

  rv.DeleteParas(0,i);

end;


Call it as

DeleteFirstNParas(rv, 20);


This function requires last version of RV.

DeleteParas automatically quickly updates (reformats) RV, so you need not to

call Format.


From description of this function:


Deletes paragraph(s) containing items from FirstItemNo to LastItemNo.

  This is an unique method - unlike all other methods of TRichView,

  it quickly reformats RichView. This method requires document to be

  formatted before calling, and leaves it formatted after.

  But it is still a "viewer-style" method, i.e. it does not update

  undo buffers, does not check ReadOnly property, etc.

  This method is specially for chat/log windows.

  By the way, if you use RichView as chat/log window (i.e. use FormatTail

  and/or DeleteParas), please write a line

  MyRichView.RVData.Flags :=

MyRichView.RVData.Flags-[rvflUseExternalLeading];

  somewhere in FormCreate. Results will be more accurate for large fonts.







Powered by ABC Amber Outlook Express Converter