纯delphi代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
private
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
if (anObject = Edit1) then
begin
ShowMessage('saf');
end;
end;
end;
procedure TForm1.CMMouseLeave(var Msg: TMessage);
var
anObject: TObject;
begin
anObject := TObject(Msg.lParam);
if anObject = nil then
begin
end;
end;
end.