您的位置:首页 > 其它

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

2015-12-02 06:45 513 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: