本人是个菜菜鸟,有个不正规的方法,嫌继承太麻烦,也不会 上次看到一个显示hint的方法,变通一下来解决响应mouse进入进出button的问题,先设button1.hint:='button1' procedure ShowHint(Sender: TObject);procedure TForm1.FormCreate(Sender: TObject); begin //... Application.OnHint := ShowHint; //... end;procedure TForm1.ShowHint(Sender: TObject); begin if Application.Hint='button1' then begin showmessage('mouse is over button1'); end end;
声明一个消息处理过程 procedure CMMouseLeave(var Message: TMessage); message CM_MouseLeave;实现代码 procedure TForm1.CMMouseLeave(var Message: TMessage); begin if TObject(Message.LParam) = Button1 then ShowMessage('鼠标离开了'); end;
上次看到一个显示hint的方法,变通一下来解决响应mouse进入进出button的问题,先设button1.hint:='button1'
procedure ShowHint(Sender: TObject);procedure TForm1.FormCreate(Sender: TObject);
begin
//...
Application.OnHint := ShowHint;
//...
end;procedure TForm1.ShowHint(Sender: TObject);
begin
if Application.Hint='button1' then
begin
showmessage('mouse is over button1');
end
end;
procedure CMMouseLeave(var Message: TMessage); message CM_MouseLeave;实现代码
procedure TForm1.CMMouseLeave(var Message: TMessage);
begin
if TObject(Message.LParam) = Button1 then
ShowMessage('鼠标离开了');
end;