利用IS 操作副可轻松搞定。
IF SENDER IS TButton then
With (Sender As TButton ) do
begin
{do somthing};
end;
IF SENDER IS TButton then
With (Sender As TButton ) do
begin
{do somthing};
end;
解决方案 »
- WINEXEC有问!
- 如何多线程拷贝一个目录
- delphi8真怪,莫名其妙报错
- 怎么在d7里添加fastnet控件,他对应的bpl文件是那一个????????
- 用adoquery的那个方法能删除掉在dbgrid里指定的数据?或是删除指定的记录位置(第几个记录)的数据?
- 如何得到dbgrid中任一个cell所对应的字段名?
- 又一个关于installshield professional的奇怪问题!
- 我传递一个Sender: TObject参数有什么用途哪?
- 急急急! Couldn't find NTLDB 是什么意思呀?
- HP打印机打印A5,B5纸的问题。有没报表高手
- 帮帮我,各位大侠。(关于OLE)
- 急需大富翁论坛的离线阅读器
2. 鼠标离开没有消息,但父窗口会得到消息,可在父窗口的MOUSEMOVE消息处理中处理;另外,也可以做一个定时器,在鼠标移入控件时启动定时器,每个一段较短的时间就检查鼠标是否在控件上,如果没有则说明鼠标移出了
如果需要的话可以给你一段VC的例子
从Tlabel继承,加一个focuscolor属性。
用了鼠标进入和离开两个消息。unit HxLabel;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
THxLabel = class(TLabel)
private
FFcolor:Tcolor;
FoldColor:Tcolor;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
procedure CMMSENTER(var Msg: TMessage);message CM_MOUSEENTER;
procedure CMMSLEAVE(var Msg: TMessage);message CM_MOUSELEAVE;
published
property FocusColor:Tcolor read FFcolor write FFcolor;
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Hxsoft', [THxLabel]);
end;procedure THxlabel.CMMSENTER(var Msg: TMessage);
begin
//鼠标进入
Foldcolor:=self.font.Color;
self.Font.Color:= FFcolor;
end;procedure THxlabel.CMMSLEAVE(var Msg: TMessage);
begin
//鼠标离开
self.font.Color:=Foldcolor;
end;end.
然後用IS來判斷SENDER是何控件, 完了用AS進行轉換后再對其FONT.COLOR進行賦值
IF SENDER IS TButton then
With (Sender As TButton ) do
begin
font.color:=/////
end;
然后其他需要的组件把OnMouseMove指定为这个过程就行了。
2、WM_MOUSEHOVER和WM_MOUSELEAVE两条消息用过没有?希望对你有所帮助。