如何在按纽或标签上做超级链接? 如何在按纽或标签上做超级链接? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 标签的字体改成兰,加下划线。然后设置标签的Cursor为crHandPoint。在标签的OnClick事件中调你想要的连接。 "在标签的OnClick事件中调你想要的连接。"具体的语句怎么写呢? 比如:http://www.htwchina.com或 d:\cjb\dd.doc 年如果想直接调用ie进行访问的话就得引入一个shellapi单元,调用其中的windows api函数了. ShellExecute(Handle,'open',PChar('C:\Program Files\Internet Explorer\IEXPLORE.EXE'),'http://www.htwchina.com',nil,SW_SHOW);或者:ShellExecute(Handle,'open',PChar('d:\cjb\dd.doc'),nil,nil,SW_SHOW); 超链接标签控件源码: THyperLabel = class(TLabel) private { Private declarations } FHoverFont: TFont; FHoverColor: TColor; FHoverCursor: TCursor; FOldCursor: TCursor; FOldFont: TFont; FOldColor: TColor; FOldScreenCursor: TCursor; FOnMouseEnter: TNotifyEvent; FonMouseLeave: TNotifyEvent; FURL: string; FHCursor: HCURSOR; procedure FSetHoverFont(value: TFont); procedure FSetHoverColor(value: TColor); procedure FSetOnMouseLeave(value: TNotifyEvent); procedure FSetOnMouseEnter(value: TNotifyEvent); procedure FSetHoverCursor(value: TCursor); procedure FSetURL(value: string); protected { Protected declarations } procedure cmmouseenter(var Msg: TMessage); message CM_MOUSEENTER; procedure cmmouseleave(var msg: TMessage); message CM_MOUSELEAVE; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Click; override; published { Published declarations } property URL: string read FURL write FSetURL; property HoverFont: TFont read FHoverFont write FSetHoverFont; property HoverColor: TColor read FHoverColor write FSetHoverColor stored true default clBtnFace; property HoverCursor: TCursor read FHoverCursor write FSetHoverCursor stored true default crHandPoint; property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FSetOnMouseEnter; property OnMouseLeave: TNotifyEvent read FonMouseLeave write FSetOnMouseLeave; end;procedure THyperLabel.FSetHoverColor(value: TColor);begin if FHoverColor <> value then FHoverColor := value;end;procedure THyperLabel.FSetHoverCursor(value: TCursor);begin if value <> FHoverCursor then FHoverCursor := value;end;procedure THyperLabel.FSetHoverFont(value: TFont);begin FHoverFont.Assign(value);end;procedure THyperLabel.FSetOnMouseEnter(value: TNotifyEvent);begin if @FOnMouseEnter <> @value then FOnMouseEnter := Value;end;procedure THyperLabel.FSetOnMouseLeave(value: TNotifyEvent);begin if @FonMouseLeave <> @value then FonMouseLeave := value;end;procedure THyperLabel.FSetURL(value: string);begin if Uppercase(value) <> Uppercase(FURL) then FURL := value;end;procedure THyperLabel.cmmouseenter(var Msg: TMessage);begin FOldFont.Assign(Font); Font.Assign(FHoverFont); FOldColor := Color; Color := FHoverColor; FOldCursor := Cursor; FHCursor := LoadCursor(0, IDC_HAND); FOldScreenCursor := Screen.Cursors[crHandPoint]; Screen.Cursors[crHandPoint] := FHCursor; Cursor := crHandPoint; if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);end;procedure THyperLabel.cmmouseleave(var Msg: TMessage);begin Font.Assign(FOldFont); Color := FOldColor; DestroyCursor(FHCursor); Screen.Cursors[crHandPoint] := FOldScreenCursor; Cursor := FOldCursor; if Assigned(FonMouseLeave) then FOnMouseLeave(Self);end;constructor THyperLabel.Create(AOwner: TComponent);begin inherited; URL := ''; FHoverFont := TFont.Create; FOldFont := TFont.Create; FHoverFont.Assign(Font); FHoverFont.Color := clBlue; FHoverFont.Style := FHoverFont.Style + [fsUnderLine]; FHoverColor := clBtnFace; FHoverCursor := crHandPoint;end;destructor THyperLabel.Destroy;begin FHoverFont.Free; FOldFont.Free; inherited;end;procedure THyperLabel.Click;var Temp: string;begin inherited; Temp := Copy(FURL, 1, 5); if temp='' then exit; if UpperCase(Temp) = 'HTTP:' then ShellExecute(Parent.Handle, 'open', 'explorer.exe', pchar(FURL), nil, SW_SHOW) else ShellExecute(Parent.Handle, 'open', pchar(FURL), nil, nil, SW_SHOW);end;-----------------------搞定-------------------------------- 表要忘记在前面uses申明shellapi 万分感谢大家帮忙解释这个单元是在干什么的?? 關於MSN與雅虎通的輔助工具設計 进度条的进度显示问题 怎样通过代码实现启动本机的SQLServer服务? 请教!!!!!!!!!!!!!!!! 关于数据库恢复的问题,急!! 如何将配置信息写入.exe内(象ShareQQ)? 项目合作,需要用openGL做三维地形环境(成都) DELPHI XE5中编辑出错,请问可能是什么原因 多层系统socket连接,最多可以连接多少客户?? 老话题了,禁止程序二次运行,可我的程序是托盘程序,于是新的问题产生了? RPC服务器不可用,可能是什么原因?
然后设置标签的Cursor为crHandPoint。
在标签的OnClick事件中调你想要的连接。
具体的语句怎么写呢?
或者:
ShellExecute(Handle,'open',PChar('d:\cjb\dd.doc'),nil,nil,SW_SHOW);
THyperLabel = class(TLabel)
private
{ Private declarations } FHoverFont: TFont;
FHoverColor: TColor;
FHoverCursor: TCursor;
FOldCursor: TCursor;
FOldFont: TFont;
FOldColor: TColor;
FOldScreenCursor: TCursor;
FOnMouseEnter: TNotifyEvent;
FonMouseLeave: TNotifyEvent;
FURL: string;
FHCursor: HCURSOR;
procedure FSetHoverFont(value: TFont);
procedure FSetHoverColor(value: TColor);
procedure FSetOnMouseLeave(value: TNotifyEvent);
procedure FSetOnMouseEnter(value: TNotifyEvent);
procedure FSetHoverCursor(value: TCursor);
procedure FSetURL(value: string);
protected
{ Protected declarations }
procedure cmmouseenter(var Msg: TMessage); message CM_MOUSEENTER;
procedure cmmouseleave(var msg: TMessage); message CM_MOUSELEAVE; public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Click; override;
published
{ Published declarations }
property URL: string read FURL write FSetURL;
property HoverFont: TFont read FHoverFont write FSetHoverFont;
property HoverColor: TColor read FHoverColor write FSetHoverColor stored true default clBtnFace;
property HoverCursor: TCursor read FHoverCursor write FSetHoverCursor stored true default crHandPoint;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FSetOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FonMouseLeave write FSetOnMouseLeave; end;procedure THyperLabel.FSetHoverColor(value: TColor);
begin
if FHoverColor <> value then
FHoverColor := value;
end;procedure THyperLabel.FSetHoverCursor(value: TCursor);
begin
if value <> FHoverCursor then
FHoverCursor := value;
end;procedure THyperLabel.FSetHoverFont(value: TFont);
begin
FHoverFont.Assign(value);
end;procedure THyperLabel.FSetOnMouseEnter(value: TNotifyEvent);
begin
if @FOnMouseEnter <> @value then
FOnMouseEnter := Value;
end;procedure THyperLabel.FSetOnMouseLeave(value: TNotifyEvent);
begin
if @FonMouseLeave <> @value then
FonMouseLeave := value;
end;procedure THyperLabel.FSetURL(value: string);
begin
if Uppercase(value) <> Uppercase(FURL) then
FURL := value;
end;
procedure THyperLabel.cmmouseenter(var Msg: TMessage);
begin
FOldFont.Assign(Font);
Font.Assign(FHoverFont); FOldColor := Color;
Color := FHoverColor; FOldCursor := Cursor;
FHCursor := LoadCursor(0, IDC_HAND);
FOldScreenCursor := Screen.Cursors[crHandPoint];
Screen.Cursors[crHandPoint] := FHCursor;
Cursor := crHandPoint; if Assigned(FOnMouseEnter) then
FOnMouseEnter(Self);
end;procedure THyperLabel.cmmouseleave(var Msg: TMessage);
begin
Font.Assign(FOldFont);
Color := FOldColor;
DestroyCursor(FHCursor);
Screen.Cursors[crHandPoint] := FOldScreenCursor;
Cursor := FOldCursor;
if Assigned(FonMouseLeave) then
FOnMouseLeave(Self);
end;constructor THyperLabel.Create(AOwner: TComponent);
begin
inherited;
URL := '';
FHoverFont := TFont.Create;
FOldFont := TFont.Create;
FHoverFont.Assign(Font);
FHoverFont.Color := clBlue;
FHoverFont.Style := FHoverFont.Style + [fsUnderLine];
FHoverColor := clBtnFace;
FHoverCursor := crHandPoint;end;destructor THyperLabel.Destroy;
begin
FHoverFont.Free;
FOldFont.Free;
inherited;
end;
procedure THyperLabel.Click;
var
Temp: string;
begin
inherited;
Temp := Copy(FURL, 1, 5);
if temp='' then exit;
if UpperCase(Temp) = 'HTTP:' then
ShellExecute(Parent.Handle, 'open', 'explorer.exe', pchar(FURL), nil, SW_SHOW)
else
ShellExecute(Parent.Handle, 'open', pchar(FURL), nil, nil, SW_SHOW);
end;
-----------------------搞定--------------------------------