怎样才能使鼠标越过speedbutton时,speedbutton变色?变图标??(要源码)(200分)

  • 主题发起人 主题发起人 bluehouse
  • 开始时间 开始时间
B

bluehouse

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样才能使鼠标越过speedbutton时,speedbutton变色?变图标?(要源码)
 
//不写控件是很难搞定的了。。
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.

 
var
b1,b2:TBitmap;
isb1:boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
b1:=TBitmap.create;
b1.LoadFromFile('c:/windows/bubbles.bmp');
Isb1:=true;
speedbutton1.Glyph:=b1;

b2:=TBitmap.create;
b2.LoadFromFile('c:/windows/tiles.bmp');
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
b1.free;
b2.free;
end;

procedure TForm1.SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if not(isb1) then
begin
speedbutton1.Glyph:=b1;
isb1:=true;
end;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if isb1 then
begin
speedbutton1.Glyph:=b2;
isb1:=false;
end;
end;
 
我不会编控件,请将源码发eMIAL:thebluehouse@163.com
 
后退
顶部