放一个Timer procedure TForm1.Timer1Timer(Sender: TObject); var p:TPoint; h:HWND; begin GetCursorPos(p); h:=WindowFromPoint(p); Label1.Caption:=FindControl(h).Hint; end;
楼上的方法可行将Timer的Interval设置小一点
最好加个判断procedure TForm1.Timer1Timer(Sender: TObject); var p: TPoint; h: HWND; begin GetCursorPos(p); h := WindowFromPoint(p); if FindControl(h).ShowHint then Label1.Caption := FindControl(h).Hint; end;
type TForm1 = class(TForm) Label1: TLabel; .................... procedure FormCreate(Sender: TObject); private { Private declarations } procedure OnDisplayHint(Sender: TObject); public { Public declarations } end; ................ implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject); begin Application.OnHint := OnDisplayHint; end;procedure TForm1.OnDisplayHint(Sender: TObject); begin label1.Caption := GetLongHint(application.Hint); end;
procedure TForm1.Timer1Timer(Sender: TObject);
var p:TPoint;
h:HWND;
begin
GetCursorPos(p);
h:=WindowFromPoint(p);
Label1.Caption:=FindControl(h).Hint;
end;
var
p: TPoint;
h: HWND;
begin
GetCursorPos(p);
h := WindowFromPoint(p);
if FindControl(h).ShowHint then Label1.Caption := FindControl(h).Hint;
end;
TForm1 = class(TForm)
Label1: TLabel;
....................
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure OnDisplayHint(Sender: TObject);
public
{ Public declarations }
end;
................
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnHint := OnDisplayHint;
end;procedure TForm1.OnDisplayHint(Sender: TObject);
begin
label1.Caption := GetLongHint(application.Hint);
end;
在华丽的ApplicationEvents空间的Event中有一个华丽的OnHint~
把这句写进去就行鸟~
label1.Caption := GetLongHint(application.Hint);
可以写在ApplicationEvents的OnShowHint中~
procedure TForm1.ApplicationEvents1ShowHint(var HintStr: string;
var CanShow: Boolean; var HintInfo: THintInfo);
其中HintStr为Hint的内容~
CanShow改为False就不出现Hint~
HintInfo为Hint的相关信息~
THintInfo类定义在Forms单元~
看着办吧~
THintInfo = record
HintControl: TControl;
HintWindowClass: THintWindowClass;
HintPos: TPoint;
HintMaxWidth: Integer;
HintColor: TColor;
CursorRect: TRect;
CursorPos: TPoint;
ReshowTimeout: Integer;
HideTimeout: Integer;
HintStr: string;
HintData: Pointer;
end;