请问在delphi中如何实现超级链结的功能,比如一点label1框就弹出ie转向www.sohu.com 用API函数:好象是shellexec(...)这个函数,在delphi中查一下帮助就行了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TForm1.N4Click(Sender: TObject);begin ShellExecute(0,'open','http://www.sohu.com,nil,nil,sw_normal);end; to cultra(协作者):程序调不过去,是否得引用单元 ? ShellExecute(0,nil,'http://www.sohu.com',nil,nil,sw_normal); uses ShellAPIShellExecute(Handle,'open',PChar(Label19.Caption),nil,nil,SW_SHOWNORMAL); //pasunit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; procedure Label2MouseEnter(Sender: TObject); procedure Label2MouseLeave(Sender: TObject); procedure Label1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}uses ShellApi;procedure TForm1.Label2MouseEnter(Sender: TObject);begin TLabel(Sender).Font.Color := clBlue; TLabel(Sender).Font.Style := [fsUnderline];end;procedure TForm1.Label2MouseLeave(Sender: TObject);begin TLabel(Sender).Font.Color := clWindowText; TLabel(Sender).Font.Style := [];end;procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin ShellExecute(0, 'OPEN', PChar(TLabel(Sender).Caption), nil, nil, SW_NORMAL);end;end.//dfmobject Form1: TForm1 Left = 192 Top = 107 Width = 544 Height = 375 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 8 Top = 48 Width = 99 Height = 13 Caption = 'http://www.csdn.net' OnMouseDown = Label1MouseDown OnMouseEnter = Label2MouseEnter OnMouseLeave = Label2MouseLeave end object Label2: TLabel Left = 8 Top = 104 Width = 104 Height = 13 Caption = 'http://www.sohu.com' OnMouseDown = Label1MouseDown OnMouseEnter = Label2MouseEnter OnMouseLeave = Label2MouseLeave endend object Label1: TLabel //.... Cursor = crHandPoint //.... end object Label2: TLabel //.... Cursor = crHandPoint //.... end ShellExecute(Handle, 'OPEN', PChar(TLabel(Sender).Caption), nil, nil, SW_NORMAL);// ~~~~~~ 抱歉,忘了。interfaceuses ShellAPI; ShellExecute(0,'open','http://www.sohu.com',nil,nil,sw_normal);记住在Uses 后加上ShellAPI 再次请教:关于combobox中加入item的几种写法有什么区别啊? 怎样隐藏任务栏? Object pascal 的静态方法,虚拟方法,动态方法有何不同?如果理解这三种方法? 复杂数据库问题:关于combobox 哪位有用Indy实现局域网聊天的源码? 数据库构架编辑器 发布 用Delphi开发的ActiveForm,浏览器中的Messenger,请各位都来看看! 关于DBGRID字段显示问题 痛恨Delphi的15个理由 对于拨号问题 寻求既懂delphi 又懂c++Builder的高手来帮忙!帮我翻译一下这段程序! 老千,那个贴子恢复不了了,只好另开一个贴子//牛虻
begin
ShellExecute(0,'open','http://www.sohu.com,nil,nil,sw_normal);
end;
ShellExecute(Handle,'open',PChar(Label19.Caption),nil,nil,SW_SHOWNORMAL);
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure Label2MouseEnter(Sender: TObject);
procedure Label2MouseLeave(Sender: TObject);
procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
ShellApi;procedure TForm1.Label2MouseEnter(Sender: TObject);
begin
TLabel(Sender).Font.Color := clBlue;
TLabel(Sender).Font.Style := [fsUnderline];
end;procedure TForm1.Label2MouseLeave(Sender: TObject);
begin
TLabel(Sender).Font.Color := clWindowText;
TLabel(Sender).Font.Style := [];
end;procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ShellExecute(0, 'OPEN', PChar(TLabel(Sender).Caption), nil, nil, SW_NORMAL);
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 48
Width = 99
Height = 13
Caption = 'http://www.csdn.net'
OnMouseDown = Label1MouseDown
OnMouseEnter = Label2MouseEnter
OnMouseLeave = Label2MouseLeave
end
object Label2: TLabel
Left = 8
Top = 104
Width = 104
Height = 13
Caption = 'http://www.sohu.com'
OnMouseDown = Label1MouseDown
OnMouseEnter = Label2MouseEnter
OnMouseLeave = Label2MouseLeave
end
end
//....
Cursor = crHandPoint
//....
end
object Label2: TLabel
//....
Cursor = crHandPoint
//....
end
// ~~~~~~