以下是我写的代码,我故意让HintWindow盖在Button上面,如果单击HintWindow,弹出的是Button1Click而没有hintclick,是不是HintWindow是透明的?
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TXXHintWindow = class(THintWindow)
protected
procedure MyClick(Sender: TObject);
public
constructor Create(aOwner: TComponent); override;
end;
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TXXHintWindow.MyClick(Sender: TObject);
begin
inherited;
ShowMessage('hintclick');
end;
constructor TXXHintWindow.Create(aOwner: TComponent);
begin
inherited;
Self.OnClick := MyClick;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
x: TXXHintWindow;
R: TRect;
AHint: string;
begin
ShowMessage('button1click');
AHint := 'asdfsfdsfsdf';
x := TXXHintWindow.Create(Self);
R := x.CalcHintRect(Screen.Width, AHint, nil);
OffsetRect(R, clienttoscreen(Point(Button1.Left, button1.Top)).x, clienttoscreen(Point(Button1.Left, button1.Top)).y);
x.ActivateHint(R, AHint);
end;
end.