//不写控件是很难搞定的了。。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TMyBitBtn = class(TBitBtn)
private
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
end;
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
BT:TMyBitBtn;
end;
implementation
procedure TMyBitBtn.CMMouseEnter(var Message: TMessage);
begin
inherited;
Font.Color:=clRed;//可以改成换图片的代码
update;
end;
procedure TMyBitBtn.CMMouseLeave(var Message: TMessage);
begin
inherited;
Font.Color:=clWindows;//可以改成换图片的代码
update;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
BT:=TMyBitBtn.Create(Self);
BT.Caption:='MyBitBtn';
BT.Parent:=Self;
BT.left:=200;
BT.top:=200;
end;
end.