How to caculate the current item top-y on the pge ?
How to caculate the current item top-y on the pge ?
How to caculate the current item top-y on the pge in the function TSRichViewEdit.PaintPage?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The code calculating the rectangle of the current item (or the current part of the item for multiline text)
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).
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;
Demos\CustomDraw\Rectangles\DrawAtCaret\
The result is coordinates in zoom=100%, relative to the page (i.e. coordinates needed in OnPaintPage).