How to make a particular line to topmost?

General TRichView support forum. Please post your questions here
Post Reply
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

How to make a particular line to topmost?

Post by Jim Knopf »

How can I make the line where the cursor is, to the topmost of a TRichViewEdit?
Sergey Tkachenko
Site Admin
Posts: 17254
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to make a particular line to topmost?

Post by Sergey Tkachenko »

Do you want to scroll to show the caret on top?

The simplest code is:

Code: Select all

var
  R: TRect;
  ItemPart: Integer;

...
 with RichViewEdit1.TopLevelEditor do
  begin
    ItemPart := RVData.GetItemPart(CurItemNo, OffsetInCurItem,
      IsCaretAtTheBeginningOfLine);
    RichViewEdit1.GetItemCoordsEx(RVData, CurItemNo, ItemPart, False, R);
  end;
  RichViewEdit1.ScrollTo(R.Top);
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: How to make a particular line to topmost?

Post by Jim Knopf »

Perfect, that's it. Thank you!
Post Reply