unit UrlLabel;interfaceuses
SysUtils, Classes, Controls, StdCtrls,Graphics,ShellAPI,Windows,Messages;
type
TUrlKind = (Html,Email,Ftp);
TUrlLabel = class(TLabel)
private
FLinkUrl: string;
FUrlKind: TUrlKind;
FHoverColor: TColor;
procedure SetLinkUrl(const Value: string);
procedure SetUrlKind(const Value: TUrlKind);
procedure SetHoverColor(const Value: TColor);
{ Private declarations }
protected
procedure Click;override;
procedure MouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure MouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
public
constructor Create(AOwner:TComponent);override;
published
property LinkUrl:string read FLinkUrl write SetLinkUrl;
property UrlKind:TUrlKind read FUrlKind write SetUrlKind default Html;
property HoverColor:TColor read FHoverColor write SetHoverColor default clred;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('ttt', [TUrlLabel]);
end;
constructor TUrlLabel.Create(AOwner:TComponent);
begin
inherited;
Font.Color := clblue;
end;
procedure TUrlLabel.Click;
var head:string;
begin
inherited;
//
end;
procedure TUrlLabel.MouseEnter(var Message: TMessage);
begin
Font.Color := HoverColor;
Font.Style := [fsUnderLine];
Cursor :=crHandPoint;
end;
procedure TUrlLabel.MouseLeave(var Message: TMessage);
begin
Font.Color := clblue;
Font.Style := Font.Style - [fsUnderLine];
Cursor :=crDefault;
end;
procedure TUrlLabel.SetLinkUrl(const Value: string);
begin
FLinkUrl := Value;
end;procedure TUrlLabel.SetUrlKind(const Value: TUrlKind);
begin
if Value = Html then
LinkUrl := 'Http://'
else if Value = Email then
LinkUrl := 'MailTo:'
else if Value = Ftp then
LinkUrl := 'Ftp://';
FUrlKind := Value;
end;procedure TUrlLabel.SetHoverColor(const Value: TColor);
begin
FHoverColor := Value;
end;end.1.procedure TUrlLabel.MouseEnter(var Message: TMessage);
begin
Font.Color := HoverColor;
Font.Style := [fsUnderLine]; //我这里只有这一句加下划线的代码,为什么托一个我的控件进去,就出现了下划线?我只想在鼠标移动到位置时有下划线怎么处理?
Cursor :=crHandPoint;
end;
2.procedure TUrlLabel.SetHoverColor(const Value: TColor);
begin
FHoverColor := Value;//我在设计视图的对象树中调整了FHoverColor后,发现窗口的URLLabel控件的颜色也变了,运行程序后URLLabel的颜色也成FHoverColor了,这是怎么回事?我应该怎么改呢?只想让它在鼠标移到控件上时改变颜色。
end;
SysUtils, Classes, Controls, StdCtrls,Graphics,ShellAPI,Windows,Messages;
type
TUrlKind = (Html,Email,Ftp);
TUrlLabel = class(TLabel)
private
FLinkUrl: string;
FUrlKind: TUrlKind;
FHoverColor: TColor;
procedure SetLinkUrl(const Value: string);
procedure SetUrlKind(const Value: TUrlKind);
procedure SetHoverColor(const Value: TColor);
{ Private declarations }
protected
procedure Click;override;
procedure MouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure MouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
public
constructor Create(AOwner:TComponent);override;
published
property LinkUrl:string read FLinkUrl write SetLinkUrl;
property UrlKind:TUrlKind read FUrlKind write SetUrlKind default Html;
property HoverColor:TColor read FHoverColor write SetHoverColor default clred;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('ttt', [TUrlLabel]);
end;
constructor TUrlLabel.Create(AOwner:TComponent);
begin
inherited;
Font.Color := clblue;
end;
procedure TUrlLabel.Click;
var head:string;
begin
inherited;
//
end;
procedure TUrlLabel.MouseEnter(var Message: TMessage);
begin
Font.Color := HoverColor;
Font.Style := [fsUnderLine];
Cursor :=crHandPoint;
end;
procedure TUrlLabel.MouseLeave(var Message: TMessage);
begin
Font.Color := clblue;
Font.Style := Font.Style - [fsUnderLine];
Cursor :=crDefault;
end;
procedure TUrlLabel.SetLinkUrl(const Value: string);
begin
FLinkUrl := Value;
end;procedure TUrlLabel.SetUrlKind(const Value: TUrlKind);
begin
if Value = Html then
LinkUrl := 'Http://'
else if Value = Email then
LinkUrl := 'MailTo:'
else if Value = Ftp then
LinkUrl := 'Ftp://';
FUrlKind := Value;
end;procedure TUrlLabel.SetHoverColor(const Value: TColor);
begin
FHoverColor := Value;
end;end.1.procedure TUrlLabel.MouseEnter(var Message: TMessage);
begin
Font.Color := HoverColor;
Font.Style := [fsUnderLine]; //我这里只有这一句加下划线的代码,为什么托一个我的控件进去,就出现了下划线?我只想在鼠标移动到位置时有下划线怎么处理?
Cursor :=crHandPoint;
end;
2.procedure TUrlLabel.SetHoverColor(const Value: TColor);
begin
FHoverColor := Value;//我在设计视图的对象树中调整了FHoverColor后,发现窗口的URLLabel控件的颜色也变了,运行程序后URLLabel的颜色也成FHoverColor了,这是怎么回事?我应该怎么改呢?只想让它在鼠标移到控件上时改变颜色。
end;
解决方案 »
- 请问一下,我做了两个FORM,但是想运行的时候,run 的按钮时灰色的。
- 提个严重的CSDN问题
- 救命!!!电脑复制文本内容后粘贴不了。。
- 设计MIS系统时,如何应用面向对象设计方法.请高手指教!
- 为什么要开事务,听说是为了安全,可是我看不出来,
- ADOTable1.Locate出错。
- to sweethzp(黄纸片),to BlueTrees(蜗牛), hahafan(注意!此人前途迷茫)请进,还有一问
- 如何使桌面右下角的小图标闪烁???急!!!!!!!!!!!!!!!
- 急救!!为什么数据表的字段用中文总是出错
- 用treeview.selected.属性存储多个字符串信息,可以吗?
- 找到一个很好的P2P,完整的服务端,和客户端直接编译
- 一个form中多个actionlist的问题,求解
...