我试了一下,没有错呀,代码再贴给你吧。
控件代码unit NetLabel;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls, ShellApi,
Graphics;type
TNetLabel = class(TLabel)
private
{ Private declarations }
protected
{ Protected declarations }
procedure Click; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('rainbowsoft', [TNetLabel]);
end;{ TNetLabel }procedure TNetLabel.Click;
begin
if Pos('@', Caption) <> 0 then
ShellExecute(0, nil, Pchar('mailto:' + Caption), nil, nil, SW_ShowNormal)
else
ShellExecute(0, nil, Pchar(Caption), nil, nil, SW_ShowNormal);
inherited;
end;constructor TNetLabel.Create(AOwner: TComponent);
begin
inherited;
Font.Color := clBlue;
Font.Style := Font.Style + [fsUnderLine];
Cursor := crHandPoint;
end;end.//窗体单元代码
uses NetLabel;procedure TForm1.Button1Click(Sender: TObject);
var
MyNetLabel: TNetLabel;
begin
MyNetLabel := TNetLabel.Create(self);
MyNetLabel.Caption := '[email protected]';
MyNetLabel.Parent := Self;
end;
控件代码unit NetLabel;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls, ShellApi,
Graphics;type
TNetLabel = class(TLabel)
private
{ Private declarations }
protected
{ Protected declarations }
procedure Click; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('rainbowsoft', [TNetLabel]);
end;{ TNetLabel }procedure TNetLabel.Click;
begin
if Pos('@', Caption) <> 0 then
ShellExecute(0, nil, Pchar('mailto:' + Caption), nil, nil, SW_ShowNormal)
else
ShellExecute(0, nil, Pchar(Caption), nil, nil, SW_ShowNormal);
inherited;
end;constructor TNetLabel.Create(AOwner: TComponent);
begin
inherited;
Font.Color := clBlue;
Font.Style := Font.Style + [fsUnderLine];
Cursor := crHandPoint;
end;end.//窗体单元代码
uses NetLabel;procedure TForm1.Button1Click(Sender: TObject);
var
MyNetLabel: TNetLabel;
begin
MyNetLabel := TNetLabel.Create(self);
MyNetLabel.Caption := '[email protected]';
MyNetLabel.Parent := Self;
end;
却不知以前的怎么错了??
有没有专门介绍Delphi编写组件的书???VB的有哦。
谢谢
你看看你的组件继承的基类是不是for windows的.