- Offizieller Beitrag
>>I need to be able to calculate the precise position, in twips from the left and top of the page rect, of the mouse cursor as it moves across the wprichtext. I also need to know what page it is over. <<
<pre>procedure TForm1.WPRichText1MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var XOfPage, YOfPage, aY, aX, PageNo,cp :Integer;
par : PTParagraph;
lin : PTLine;
begin
// First we need to find the page which is 'under' the mouse
WPRichText1.GetLineFromXY(x,y,par,lin,cp);
// If there is a page:
if lin<>nil then
begin
PageNo := lin^.pagenum;
// Find first line with this page
par := WPRichText1.FirstPar;
while par<>nil do
begin
lin := par^.line;
par := par^.next;
while lin<>nil do
begin
if lin^.pagenum = PageNo then
begin
par := nil;
Break;
end;
lin := lin^.next;
end;
end;
if lin<>nil then
begin
YOfPage := lin^.y_start - lin^.t_xtra - lin^.line_top- WPRichText1.TopOffset;
aY := MulDiv( WPRichText1.Memo.ScreenToTwip(y ) - YOfPage
, 1440, WPRichText1.Header.FFontYPixelsPerInch)- WPRichText1.YOffSet;
aX := MulDiv( WPRichText1.Memo.ScreenToTwip(X - WPRichText1.XOffSet) - WPRichText1.Memo.left_offset
, 1440, WPRichText1.Header.FFontXPixelsPerInch);
<b>// Do anything with aX and aY <--------- !!!</b>
end;
end;
end;</pre>