鼠标进入与离开的消息(覆盖CM_MOUSEENTER与CM_MOUSELEAVE消息)——Windows本身没有这样的消息

复制代码
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    Edit1: TEdit;
  private
    { Private declarations }
    procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.CMMouseEnter(var Msg: TMessage);
var
  anObject :        TObject;
begin
  anObject := TObject(Msg.lParam);
  //进入控件
  if anObject <> nil then
  begin
    Label1.Caption := 'Mouse Enter...'; //显示信息
  end;
end;
procedure TForm1.CMMouseLeave(var Msg: TMessage);
//退出控件
var
  anObject :        TObject;
begin
  anObject := TObject(Msg.lParam);
  if anObject <> nil then
  begin
       Label1.Caption := 'Mouse Leave...'; //显示信息
  end;
end;


end.
复制代码

http://blog.csdn.net/diligentcatrich/article/details/7010488

posted @   findumars  Views(488)  Comments(0Edit  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示