Page 1 of 1

How to caculate the current item top-y on the pge ?

Posted: Fri Sep 12, 2014 3:47 am
by yh01110
How to caculate the current item top-y on the pge in the function TSRichViewEdit.PaintPage?

Posted: Fri Sep 12, 2014 7:50 am
by Sergey Tkachenko
The code calculating the rectangle of the current item (or the current part of the item for multiline text)

Code: Select all

var
  ItemPart, FirstPageNo, LastPageNo: Integer;
  ItemPartRect: TRect;

with SRichViewEdit1.RichViewEdit.TopLevelEditor do begin
    ItemPart := RVData.GetItemPart(CurItemNo, OffsetInCurItem, IsCaretAtTheBeginningOfLine);
    SRichViewEdit1.GetItemBounds100(RVData, CurItemNo, ItemPartRect,
      FirstPageNo, LastPageNo, ItemPart);
  end;
  // the result is ItemPartRect;
This code is taken from the demo
Demos\CustomDraw\Rectangles\DrawAtCaret\

The result is coordinates in zoom=100%, relative to the page (i.e. coordinates needed in OnPaintPage).