WPCubed Product Support

Hint window next to to a hyperlink

  1. 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?

  1. I need to move the cursor over a hyperlink when the mouse moves over it.

How does WPRichText do that?

Kind regards.

Carlos Borrero

#1 ♥ 0
8.1k Views 3 users read 2 min

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;

Hope this helps.

Alessandro Fragnani

#2 ♥ 0

Alessandro, thank you for your answer.

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.

#3 ♥ 0
support

Hi,

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.

Julian

#4 ♥ 0

Julian:

Thank you for your answer, but I don't know how to solve the problem.

You advise me to write WPRichText1.GetLineFromXY. Do you mean to copy the procedure that is part of WPTools5, on my program, using WPTools6?

If the answer is yes, in what file can I find GetLineFromXY? Do I need to write GetPointFromParLin also?

Kind regards.

Carlos Borrero

#5 ♥ 0
support

Hi,

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.