当鼠标按动到SpeedButtom上面时显示另外一张图片,移走时又显示原来的图片怎样实现,谢了!! 在speedbutton的onMouseMove中写代码就行了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SpeedButtom.Glyph.Loadfromfile('c:\aa.bmp');放在 MouseMove事件里, 当鼠标移动到它上方时改为aa.bmp这样是可以的, 但移走时原来的图片怎样回来呢, 它没有移走事件, 怎样实现, 谢了 procedure TForm1.SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin speedbutton1.Glyph:=image1.Picture.Bitmap;end;不过有闪动。 :( procedure TForm1.SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);beginspeedbutton1.Glyph.LoadFromFile('c:\test1.bmp');end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);beginspeedbutton1.Glyph.LoadFromFile('c:\test2.bmp');end; 可以在Button后面的Form的MouseMove事件里面把图片在Load回来~~ 其实不一定是form,就是在包含这个speedbutton的容器中的onmousemove中load一下图片就可以了 可以这样: 如SpeedButton是放在form1上,在form1 的MouseMove事件里再把原来的图片放回来. 那你设置个变量var isIn:boolean;procedure TForm1.SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin if Not isIn then speedbutton1.Glyph:=image1.Picture.Bitmap; isIn:=True;end;记得鼠标移动到别的地方的时候把isIn设置为False 实现下面两个消息的处理方法,就行啦。 CM_MOUSEENTER CM_MOUSELEAVE 思路是这样的:用Tspeedbutton的tag作为判断条件。鼠标在按钮上 speedbutton 的 tag 为 0时 执行 tag:=1 和换图 ,鼠标在 form上是 判断 speedbutton1 的tag 为1 执行 tag:=0 和换图 这样就只执行一次了。不会闪 可以是可以,能不能用CM_MOUSELEAVE 这样不,能不能用CM_MOUSELEAVE,万分感谢 http://www.csdn.net/expert/Topic/262/262125.shtm你看看老大的回答阿!! 老大,我用的是SpeendButton1, 怎样把 procedure MouseEnter(var Msg:TMessage); message cm_mouseEnter; procedure MouseLeave(var Msg:TMessage); message cm_mouseLeave; 加到它的事件里头 老大~~~那个帖子只不过是Bitbtn~~~TLCActiveBitBtn = class(TBitBtn)你修改为TLCActiveSbtn = class(TSpeedButton)不行吗?? 老大!!!!!我不会改嘛, 能不能改一下原来的SpeedButton1, 再通过install Component安装一下呢 不行呀,我做了一个, 看不到MoseLeave属于和MouseEnter属性 tikkypeng(千两狂死郎) 老大,你快帮我解决呀!要不然 我把新建了一个form , 存名为ActiveBitBtn,把它的所有代码复制过来了然后改了它的TLCActiveBitBtn = class(TBitBtn)为 TLCActiveBitBtn = class(TBitBtn)再把procedure TLCActiveBitBtn.MouseEnter(var Msg:TMessage);begin Font.Style:=Font.Style+[fsBold]+[fsUnderline]; Font.Size:=Font.Size+2; Font.Color:=clBlue;end;procedure TLCActiveBitBtn.MouseLeave(var Msg:TMessage);begin Font.Style:=Font.Style-[fsBold]-[fsUnderline]; Font.Size:=Font.Size-2; Font.Color:=clBackground;end;全都删了,剩下unit ActiveBitBtn;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;type TLCActiveBitBtn = class(TSpeenButton) private { Private declarations } protected { Protected declarations } procedure MouseEnter(var Msg:TMessage); message cm_mouseEnter; procedure MouseLeave(var Msg:TMessage); message cm_mouseLeave; public { Public declarations } published { Published declarations } end;procedure Register;implementationprocedure Register;begin RegisterComponents('LCC', [TLCActiveBitBtn]);end; tikkypeng(千两狂死郎) 老大,你快帮我解决呀! 快点呀,看看哪儿出错了 你看看我的阿~~~~~unit PSSpeedButton;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Buttons;type TPSSpeedButton = class(TSpeedButton) private FOnMouseLeave: TNotifyEvent; procedure WZMouseLeave(var Msg:TMessage); message CM_MOUSELEAVE; { Private declarations } protected { Protected declarations } public { Public declarations } published property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave; { Published declarations } end;procedure Register;implementationprocedure Register;begin RegisterComponents('PS', [TPSSpeedButton]);end;procedure TPSSpeedButton.WZMouseLeave(var Msg: TMessage);begin inherited;//继承父类 if csLButtonDown in ControlState then begin Self.MouseUp(mbLeft,[ssLeft],0,0); end; if Assigned (FonMouseLeave) then FOnMouseLeave(Self); end;end. 这样是可以的,有MouseLeave属性,但没有MouseEnter; 可不可以加上MouseEnter属性 有东西学,tikkypeng(千两狂死郎):请问上面的代码怎样用呢? 那个是自己作的控件阿~~只不过是继承了TSpeedButton~~然后在此基础上~增加一个Mouse离开事件~~ 请教如何在fastreport中实现32开页面的套打功能,解决立即给分,谢谢 怎样建立一个链表队列 人事关系系统开发 ***请问这样的文件流操作!代码该怎么写?*** 请高手:怎样改变ListView的表头的颜色,字体. 如何让我的程序最小化的时候在闪动 请问怎样重命名一个文件 急!帮忙解决下关于shellistview和资源管理器右建菜单问题. 可怜的系统资源啊!50%?!大虾快救救我!SOS! 怎样控制lzh压缩比? BORLAND ANNOUNCES KYLIX2!!! 请问如何才能获得系统有几个驱动器?
X, Y: Integer);
begin
speedbutton1.Glyph:=image1.Picture.Bitmap;
end;
不过有闪动。 :(
X, Y: Integer);
begin
speedbutton1.Glyph.LoadFromFile('c:\test1.bmp');
end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
speedbutton1.Glyph.LoadFromFile('c:\test2.bmp');
end;
如SpeedButton是放在form1上,在form1 的MouseMove事件里再把原来的图片放回来.
var isIn:boolean;procedure TForm1.SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if Not isIn then
speedbutton1.Glyph:=image1.Picture.Bitmap;
isIn:=True;
end;记得鼠标移动到别的地方的时候把isIn设置为False
CM_MOUSELEAVE
用Tspeedbutton的tag作为判断条件。鼠标在按钮上 speedbutton 的 tag 为 0时 执行 tag:=1 和换图 ,鼠标在 form上是 判断 speedbutton1 的tag 为1 执行 tag:=0 和换图
这样就只执行一次了。不会闪
procedure MouseEnter(var Msg:TMessage); message cm_mouseEnter;
procedure MouseLeave(var Msg:TMessage); message cm_mouseLeave;
加到它的事件里头
TLCActiveSbtn = class(TSpeedButton)不行吗??
我不会改嘛, 能不能改一下原来的SpeedButton1, 再通过install Component安装一下呢
然后改了它的
TLCActiveBitBtn = class(TBitBtn)为 TLCActiveBitBtn = class(TBitBtn)
再把procedure TLCActiveBitBtn.MouseEnter(var Msg:TMessage);
begin
Font.Style:=Font.Style+[fsBold]+[fsUnderline];
Font.Size:=Font.Size+2;
Font.Color:=clBlue;
end;procedure TLCActiveBitBtn.MouseLeave(var Msg:TMessage);
begin
Font.Style:=Font.Style-[fsBold]-[fsUnderline];
Font.Size:=Font.Size-2;
Font.Color:=clBackground;
end;
全都删了,剩下
unit ActiveBitBtn;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;type
TLCActiveBitBtn = class(TSpeenButton)
private
{ Private declarations }
protected
{ Protected declarations }
procedure MouseEnter(var Msg:TMessage); message cm_mouseEnter;
procedure MouseLeave(var Msg:TMessage); message cm_mouseLeave;
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('LCC', [TLCActiveBitBtn]);
end;
unit PSSpeedButton;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons;type
TPSSpeedButton = class(TSpeedButton)
private
FOnMouseLeave: TNotifyEvent;
procedure WZMouseLeave(var Msg:TMessage); message CM_MOUSELEAVE;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('PS', [TPSSpeedButton]);
end;procedure TPSSpeedButton.WZMouseLeave(var Msg: TMessage);
begin
inherited;//继承父类
if csLButtonDown in ControlState then
begin
Self.MouseUp(mbLeft,[ssLeft],0,0);
end;
if Assigned (FonMouseLeave) then FOnMouseLeave(Self);
end;
end.