Page 1 of 1
How can I page down such that a pagebreak is at the top
Posted: Mon Aug 22, 2011 4:58 pm
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
Posted: Mon Aug 22, 2011 5:31 pm
by Sergey Tkachenko
In TRichView or ScaleRichView?
Posted: Tue Aug 23, 2011 1:17 pm
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.
Posted: Tue Aug 23, 2011 4:24 pm
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;
Posted: Tue Aug 23, 2011 4:29 pm
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.