本文介绍了如何在Delphi上使用Application.ActivateHint显示提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码尝试显示提示:

I have the following code trying to show a hint:

procedure TMyGrid.OnGridMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  aPoint: TPoint;
begin
  inherited;
  //Application.Hint := 'Hint Text';
  //Application.ShowHint := True;
  Grid.Hint := 'Hint Text';
  Grid.ShowHint := True;
  aPoint.X := X;
  aPoint.Y := Y;
  Application.ActivateHint(aPoint);
end;

但是没有提示出现.怎么了?

But there is no hint appears. What's wrong?

推荐答案

ActivateHint 希望您的点位于屏幕坐标中,而不是客户端坐标中.

ActivateHint wants your point in screen coordinates, not in client coordinates.

来自文档:

因此,您必须像这样更改方法:

So, you have to change your method like this:

procedure TMyGrid.OnGridMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  aPoint: TPoint;
begin
  inherited;
  //Application.Hint := 'Hint Text';
  Grid.Hint := 'Hint Text';
  Grid.ShowHint := True;
  aPoint.X := X;
  aPoint.Y := Y;
  aPoint := ClientToScreen(aPoint);
  Application.ActivateHint(aPoint);
end;

这篇关于如何在Delphi上使用Application.ActivateHint显示提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 05:03