这跟函数有问题
Address是一个属性,在这里使用Address:=Value会出现递归调用:你一直在更改属性,也就是调用SetAddr,结果堆栈溢出
procedure TMyLinkLabel.SetAddr(Value:string);
begin
Address:=Value;
end; 修改成
type
TLinkLabel = class(TCustomLabel)
private
{ Private declarations }
function GetAddr:string;
procedure SetAddr(Value:string);
protected
{ Protected declarations }
FAddress:String;
procedure WMLButtonDown(var msg:TWMLButtonDown);message WM_LButtonDown;
public
{ Public declarations }
constructor Create(AOwner:TComponent);OverRide;
published
{ Published declarations }
property Align;
property AutoSize;
property Cursor;
property Font;
property Hint;
property ShowHint;
Property Visible;
property Address:string read GetAddr write SetAddr;
end; procedure Register; implementation function TLinkLabel.GetAddr:string;
begin
result:=FAddress;
end; procedure TLinkLabel.SetAddr(Value:string);
begin
FAddress:=Value;
end;
procedure TLinkLabel.WMLButtonDown(var msg:TWMLButtonDown);
begin
if (Pos('http://',LowerCase(Address))=0) and (Pos('@',Address)=0) and
(Pos('ftp://',LowerCase(Address))=0) then
MessageDlg('地址无效',mtError,[mbOk],0)
else
ShellExecute(0,nil,Pchar(Address),nil,nil,SW_ShowNormal);
end; constructor TLinkLabel.Create(AOwner:TComponent);
begin
Inherited Create(AOwner);
Font.Name:='宋体';
Font.Color:=clBlue;
Font.Size:=9;
Cursor:=crHandPoint;
Address:='http://ywbtaxi.home.sohu.com';
end; procedure Register;
begin
RegisterComponents('std1', [TLinkLabel]); //std1是一个已存在的面板
end; end.
Address是一个属性,在这里使用Address:=Value会出现递归调用:你一直在更改属性,也就是调用SetAddr,结果堆栈溢出
procedure TMyLinkLabel.SetAddr(Value:string);
begin
Address:=Value;
end; 修改成
type
TLinkLabel = class(TCustomLabel)
private
{ Private declarations }
function GetAddr:string;
procedure SetAddr(Value:string);
protected
{ Protected declarations }
FAddress:String;
procedure WMLButtonDown(var msg:TWMLButtonDown);message WM_LButtonDown;
public
{ Public declarations }
constructor Create(AOwner:TComponent);OverRide;
published
{ Published declarations }
property Align;
property AutoSize;
property Cursor;
property Font;
property Hint;
property ShowHint;
Property Visible;
property Address:string read GetAddr write SetAddr;
end; procedure Register; implementation function TLinkLabel.GetAddr:string;
begin
result:=FAddress;
end; procedure TLinkLabel.SetAddr(Value:string);
begin
FAddress:=Value;
end;
procedure TLinkLabel.WMLButtonDown(var msg:TWMLButtonDown);
begin
if (Pos('http://',LowerCase(Address))=0) and (Pos('@',Address)=0) and
(Pos('ftp://',LowerCase(Address))=0) then
MessageDlg('地址无效',mtError,[mbOk],0)
else
ShellExecute(0,nil,Pchar(Address),nil,nil,SW_ShowNormal);
end; constructor TLinkLabel.Create(AOwner:TComponent);
begin
Inherited Create(AOwner);
Font.Name:='宋体';
Font.Color:=clBlue;
Font.Size:=9;
Cursor:=crHandPoint;
Address:='http://ywbtaxi.home.sohu.com';
end; procedure Register;
begin
RegisterComponents('std1', [TLinkLabel]); //std1是一个已存在的面板
end; end.
解决方案 »
- 重命名程序名字会改变运行后桌面下栏的名字,怎么固定?
- 运行出错了,请指教.
- 请问如何可以在TEdit控件中输入多行文本?
- fastreport格式化字段的问题?
- 关于adoquery获取数据集字段值的问题
- 何谓DELPHI中使用同步还是异步方式
- 读过李维写的 Delphi 5.X ADO_MTS_COM+高级程序设计篇 第9章的请进。。。。。。
- 500分求助,图片浏览的问题。急 急 急!!!!!
- 一个关于NAME的问题
- 我做的程序用的是MS SQL做后台数据库,出现的问题是在DBGRID上输入了数字后数据库便自动保存数据了
- 请教关于用DELPHI开发三层数据结构的ORACLE的BLOB字段更新问题?
- 菜鸟问各位大侠:如何将几个声音文件并成一个文件?救救我!!!
也不要使用SetAddress,GetAddress等等。
鼠标点击的时候,直接判断Caption不就可以了?