如何在delphi中加超链接,使它能打开浏览器,浏览网页?
解决方案 »
- 怎么样让窗体出现滚动条,页面内容太多,等待回答
- 用IfFtpServer不能列出目录下的文件,请个为帮忙,谢谢!!!!
- richedit右键菜单
- 怎样将一个EXE或DLL调至某一PANEL中运行?
- 为什么我的IHTMLElement接口不支持HTMLButtonElementEvents2 ??
- 关于控件的安装:只有.pas和.dhm文件~~
- 菜鸟刚学写了个数据入库、修改、查询的小程序,向高手学习。
- 我下载了一个做报表的东西叫做ereport??????/
- 给我提供好书!!!
- 数据库中建表问题
- 高手我帮看看这个是什么错误,找了两天了,还没找出来?
- 用quickrep自画报表,预览正常,打印却只有表格,无数据?
那个函数是什么我忘了
你查一下,挺好找的
sw_shownormal);
shellexecute(0,'open','www.csdn.net',nil,nil,sw_normal);
Windows, Classes, Controls, StdCtrls, SysUtils, Forms,
Graphics, ShellAPI;type
TUrlLabel = class(TLabel) private
{ Private declarations }
Url:string;
procedure ExeUrl;
procedure seturl(value:string);
protected
procedure Click;override;
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
Published
property UrlString:string read Url write seturl;
end;procedure Register;implementationconst
defaulturl:string='http://lb001.51.net';
procedure TUrlLabel.click;
begin
inherited click;
ExeUrl;
end;
constructor TUrlLabel.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Url:=defaulturl;
Caption:=Url;
font.style:=[fsUnderline];
font.color:=clBlue;
Cursor:=crHandPoint;
end;
procedure TUrlLabel.ExeUrl;
begin
shellexecute(Application.handle,nil,pchar(Url),nil,nil,SW_SHOWNORMAL);
end;
procedure TUrlLabel.seturl(value:string);
begin
Url:=value;
if csDesigning in ComponentState then
begin
Caption := Value;
//Application.MessageBox('Your changed the urlstring!','',mb_ok);
end;
end;procedure Register;
begin
RegisterComponents('mycontrols',[TUrlLabel]);
end;end.
再在label1的ONCLICK事件中加入
SellExecute(handle,nil,'http://www.whlhbh.8u8.com',nil,nil,
sw_shownormal);
如果想做更像的话可以定义LABEL1的鼠标形状定义成手形,在ONMOUSEMOVE
事件中使LABEL1的字变色。
SellExecute(handle,nil,pchar('http://www.163.com'),nil,nil,
sw_shownormal);
uses ShellApi
shellexecute(handle,nil,pchar('mailto:[email protected]'),nil,nil,sw_shownormal);