unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
private
procedure MyWndProc(var Message: TMessage);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
OldMyWndProc: TWndMethod;
implementation
{$R *.dfm}
procedure TForm1.MyWndProc(var Message: TMessage);
begin
case Message.Msg of
CM_MOUSEENTER:
bitbtn1.glyph.LoadFromFile('d:/pic2.bmp');//鼠标移入
CM_MOUSELEAVE:
bitbtn1.glyph.LoadFromFile('d:/pic1.bmp');//鼠标移来
end;
OldMyWndProc(Message);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OldMyWndProc := BitBtn1.WindowProc;
BitBtn1.windowProc := MyWndProc;
bitbtn1.glyph.LoadFromFile('d:/pic1.bmp');
end;
end.