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

General TRichView support forum. Please post your questions here
Post Reply
yh01110
Posts: 9
Joined: Thu Apr 21, 2011 12:43 am

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

Post by yh01110 »

How to caculate the current item top-y on the pge in the function TSRichViewEdit.PaintPage?
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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).
Post Reply