How can I page down such that a pagebreak is at the top

General TRichView support forum. Please post your questions here
Post Reply
dhjdhj
Posts: 2
Joined: Mon Aug 22, 2011 4:55 pm

How can I page down such that a pagebreak is at the top

Post by dhjdhj »

I'm trying to build a basic teleprompter app ---- when I press page down, I'd like the view to jump to the next "page break" such that that page break is at the top of the new view.

Any way to do this?

Thanks,
David
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In TRichView or ScaleRichView?
dhjdhj
Posts: 2
Joined: Mon Aug 22, 2011 4:55 pm

Post by dhjdhj »

Just in TRichView.

I had tried to just use special characters (e.g, ###) and used the Search function to find the next one but when I used that mechanism, the found line was always at the BOTTOM of the window rather than the top.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The following code scrolls the selection to the top:

Code: Select all

var ItemNo1, Offs1, ItemNo2, Offs2, X, Y: Integer;
begin
  RichView1.GetSelectionBounds(ItemNo1, Offs1, ItemNo2, Offs2, True);
  if ItemNo1<0 then
    exit;
  RichView1.GetItemCoords(ItemNo1, X, Y);
  RichView1..ScrollTo(y);
end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Well, the code below does the same, but more precisely (if the selection is started not on the first line of the long text item, the previous code scrolls to the first line of this item; this code scrolls to the selection).

Code: Select all

uses DLines;

var ItemNo1, Offs1, ItemNo2, Offs2: Integer;
begin
  RichView1.GetSelectionBounds(ItemNo1, Offs1, ItemNo2, Offs2, True);
  if ItemNo1<0 then
    exit;
  RichView1.RVData.Item2DrawItem(ItemNo1, Offs1, ItemNo1, Offs1);
  RichView1.ScrollTo(RichViewEdit1.RVData.DrawItems[ItemNo1].Top);
end;
This code uses some undocumented methods.

The both methods do not work properly if the selection is in table cell, but I suppose this is not a problem for your application.
Post Reply