onMouseMove事件是经常发生的。应该编写一个新Timage构件。
如下:
unit image1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls;
type
TNewimage = class(TImage)
private
FOnMouseLeave: TNotifyEvent;
FOnMouseEnter: TNotifyEvent;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
//请自己修改
RegisterComponents('Samples', [TNewimage]);
end;
{ timage1 }
procedure TNewimage.CMMouseEnter(var Message: TMessage);
begin
inherited;
if Assigned(FOnMouseEnter) then
FOnMouseEnter(Self);
end;
procedure TNewimage.CMMouseLeave(var Message: TMessage);
begin
inherited;
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;
end.
//就行了.