如何判断鼠标从Panel上移开

citytramper 2002-11-30 02:20:52
如何判断鼠标从Panel上移开
...全文
40 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
citytramper 2002-11-30
  • 打赏
  • 举报
回复
多谢 happyzsl(学习) zxfsdbj(飞飞猫) 回答我的问题,happyzsl(学习)更符合我的思路,所以分给他。
zxfsdbj 2002-11-30
  • 打赏
  • 举报
回复
我只是提供一种思路,你可以根据具体情况修改
zxfsdbj 2002-11-30
  • 打赏
  • 举报
回复
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
panel1.Caption:='鼠标在我上面';
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
panel1.Caption:='鼠标不在我上面';
end;
happyzsl 2002-11-30
  • 打赏
  • 举报
回复
学习学习:

鼠标移入称出控件的消息:

DELPHI预定义的两个消息:
CM_MOUSEENTER 和 CM_MOUSELEAVE。 Below 已经提供了部分使用它们的代码,
我试了,对TSPEEDBUTTON有效,相信对其它也有效。
unit SomeForm;
interface
type
TSomeForm = class(TForm)
private
procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
end;
implementation
procedure TSomeForm.CMMouseEnter(var Msg: TMessage);
var
anObject : TObject;
begin
{ anObject is the control over which the mouse is right now }

anObject := TObject(Msg.lParam);
if anObject nil then begin
{ First, you must find WHICH is the control under the mouse cursor, }
{ then, determine what action to do, etc... }
end;
end;
procedure TSomeForm.CMMouseLeave(var Msg: TMessage);
begin
{ anObject is the control which the mouse has just gone out of }
anObject := TObject(Msg.lParam);
if anObject nil then begin
{ First, you must find WHICH is the control }
{ the mouse cursor has just left, }
{ then, determine what action to do, etc... }
end;
end;
end.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧