I Need to show a special hint window next to a hyperlink when mouse moves over it.
To do that I need to know the screen coordinates, I have been trying the X and Y coordinates that event onMouseMove returns, but those don't seem to be the appropiate ones.
Can you please tell me how to calculate those screen coordinates?
I need to move the cursor over a hyperlink when the mouse moves over it.
I don't know if WPTools 5 and 6 works equals in this, but in WPTools 5 you should use ScreenToClient, WPRichText.GetLineFromXY and WPRichText.GetPointFromParLin.
I have done something like this (The poRect will be the Rect for a HintWindow):
procedure TYOURWPRichText.CalcHintArea(var poRect: TRect);
var
oPoint, p: TPoint;
oParagraph: TParagraph;
nPosinpar: integer;
begin
oPoint := Mouse.CursorPos;
if oPoint.x > self.Width then
oPoint.x := self.Width;
oPoint := ScreenToClient(oPoint);
if GetLineFromXY(oPoint.x, oPoint.y, oParagraph, nPosinpar) then
begin
p := GetPointFromParLin(oParagraph, nPosinpar);
p := ClientToScreen(p);
end;
OffsetRect(poRect, p.X, p.Y);
OffsetRect(poRect, 0, -(poRect.Bottom - poRect.Top));
end;
Unfortunately GetLineFromXY and GetPointFromParLin are not supported by WPTools6, and I can't find equivalent methods, so I can't solve the problem I have.
Thanks to Alessandro. Please note that this happens in a child class (procedure TYOURWPRichText.). You will need to write WPRichText1.GetLineFromXY to get the same effect.
No, You just need to reference the method as part of a TWPRichText instance and not call it if it was a global function or a function of the object in context.
if wp.GetLineFromXY(oPoint.x, oPoint.y, oParagraph, nPosinpar) then
begin
p := wp.GetPointFromParLin(oParagraph, nPosinpar);
p := ClientToScreen(p);
end;
Julian
#6♥ 0
This category is archived. No new posts are possible.