سؤال

I want to show a hint as the user moves the mouse over a TDbStringGrid. It almost works, but the hint shows high and to the left.

In my OnMouseMove, I receive X & Y, which I think are abosulte screen corrdinates, but I can use dbGrid.MouseCoord(X, Y) to get a point within the DB grid.

When I show my hint using Application.ActivateHint(), it is placed high and to the left.

Any idea what I am doing wrong?

هل كانت مفيدة؟

المحلول

I'd try to use the ClientToScreen method to convert the control's relative coordinates to screen coordinates since ActivateHint uses screen coordinates and events like OnMouseMove receives control relative ones. In code, it might look like this:

procedure TForm1.DbStringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  ScreenRelativePoint: TPoint;
begin
  ScreenRelativePoint := (Sender as TControl).ClientToScreen(Point(X, Y));
  Application.ActivateHint(ScreenRelativePoint);
end;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top