unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TImage =
class(ExtCtrls.TImage)
private
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
procedure CMMouseEnter(
var Msg: TMessage);
message CM_MOUSEENTER;
procedure CMMouseLeave(
var Msg: TMessage);
message CM_MOUSELEAVE;
public
property OnMouseEnter: TNotifyEvent
read FOnMouseEnter
write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent
read FOnMouseLeave
write FOnMouseLeave;
end;
TForm1 =
class(TForm)
Image1: TImage;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure DoOnEnter(Sender: TObject);
procedure DoOnLeave(Sender: TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TImage.CMMouseEnter(
var Msg: TMessage);
begin
if Assigned(FOnMouseEnter)
then
FOnMouseEnter(self);
Msg.Result := 0;
end;
procedure TImage.CMMouseLeave(
var Msg: TMessage);
begin
if Assigned(FOnMouseLeave)
then
FOnMouseLeave(self);
Msg.Result := 0;
end;
procedure TForm1.DoOnEnter(Sender: TObject);
begin
Label1.Caption := '
drin';
end;
procedure TForm1.DoOnLeave(Sender: TObject);
begin
Label1.Caption := '
draußen';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.OnMouseEnter := DoOnEnter;
Image1.OnMouseLeave := DoOnLeave;
end;
end.