unit bla;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TBitBtn =
class(Buttons.TBitBtn)
private
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
procedure CMMOUSEENTER(
var Msg: TMessage);
message CM_MOUSEENTER;
procedure CMMOUSELEAVE(
var Msg: TMessage);
message CM_MOUSELEAVE;
public
constructor Create(aOwner: TComponent);
override;
property OnMouseEnter: TNotifyEvent
read FOnMouseEnter
write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent
read FOnMouseLeave
write FOnMouseLeave;
end;
TForm1 =
class(TForm)
btn1: TBitBtn;
btn2: TBitBtn;
btn3: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure DoOnEnter(Sender: TObject);
procedure DoOnLeave(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TBitBtn }
procedure TBitBtn.CMMOUSEENTER(
var Msg: TMessage);
begin
inherited;
if Assigned(FOnMouseEnter)
then
FOnMouseEnter(Self);
end;
procedure TBitBtn.CMMOUSELEAVE(
var Msg: TMessage);
begin
inherited;
if Assigned(FOnMouseLeave)
then
FOnMouseLeave(Self);
end;
constructor TBitBtn.Create(aOwner: TComponent);
begin
inherited;
FOnMouseEnter :=
nil;
FOnMouseLeave :=
nil;
end;
procedure TForm1.DoOnEnter(Sender: TObject);
begin
(Sender
as TBitBtn).Font.Style := (Sender
as TBitBtn).Font.Style + [fsBold];
end;
procedure TForm1.DoOnLeave(Sender: TObject);
begin
(Sender
as TBitBtn).Font.Style := (Sender
as TBitBtn).Font.Style - [fsBold];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
btn2.OnMouseEnter := DoOnEnter;
btn2.OnMouseLeave := DoOnLeave;
end;
end.