关于label的 caption显示问题(50分)

  • 主题发起人 主题发起人 linuxcrow
  • 开始时间 开始时间
L

linuxcrow

Unregistered / Unconfirmed
GUEST, unregistred user!
当我的鼠标放到label上时(moveover时)希望caption的字体大小颜色都发生变化<br>默认label没 有moveover事件吧
 
OnMouseMove
 
OnMouseMove
 
用WINDOWS的MOUSE进入和退出功能
 
如过用onmousemove当鼠标离开是不会还原啊 !!!
 
最好的方法是用一些增加了onMouseEnter,onMouseleve事件的Label,那样会变得很简单。<br>如Rxlibk中就有这样的label.
 
//给你搞定.<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; Buttons, ExtCtrls, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br>Tmylabel=class( tlabel)<br>private<br>&nbsp; &nbsp; procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;<br>&nbsp; &nbsp; procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;<br><br>end;<br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>var<br>&nbsp; img:tmylabel;<br><br>procedure Tmylabel.CMMouseEnter(var Message: TMessage);<br>begin<br>&nbsp; //进入事件<br>end;<br><br>procedure Tmylabel.CMMouseLeave(var Message: TMessage);<br>begin<br>&nbsp; //离开事件<br>end;<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; img:=tmylabel.Create(self);<br>&nbsp; img.left:=10;<br>&nbsp; img.Top:=10;<br>&nbsp; img.Parent:=self;<br>end;
 
label1放在form上, 移上label1字体改变,鼠标到form上字体再改变,就达到你要求了<br><br>如下代码:<br>procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,<br>&nbsp; Y: Integer);<br>begin<br>label1.Font.Color:=clRed; &nbsp; //颜色改变<br>............................//加上你自己 改变字体的代码<br><br>end;<br><br>procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,<br>&nbsp; Y: Integer);<br>begin<br>label1.Font.Color:=clWhite; //颜色还原<br>............................//加上你还原字体的代码<br>end;<br>
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
907
DelphiTeacher的专栏
D
D
回复
0
查看
702
DelphiTeacher的专栏
D
D
回复
0
查看
665
DelphiTeacher的专栏
D
D
回复
0
查看
821
DelphiTeacher的专栏
D
后退
顶部