先做一个about的form
unit about;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
Tform_about = class(TForm)
Memo1: TMemo;
private
{ Private declarations }
public
{ Public declarations }
end;
var
form_about: Tform_about;
implementation
{$R *.DFM}
end.
下面是一个控件的源代码,例子
unit mybutton;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,dsgnintf,about;
type
TAboutProperty = class(TPropertyEditor)
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
tmybutton = class(TButton)
private
FAbout:TAboutProperty;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
property ABOUT:TAboutProperty read FAbout write Fabout;
{ Published declarations }
end;
procedure Register;
implementation
{ TAboutProperty }
procedure TAboutProperty.Edit;
var
about:Tform_about;
begin
about:=Tform_about.create(nil);
about.showmodal;
about.free;
end;
function TAboutProperty.GetAttributes: TPropertyAttributes;
begin
GetAttributes:=[paDialog, paReadOnly];
end;
function TAboutProperty.GetValue: string;
begin
GetValue:='(About)';
end;
procedure Register;
begin
RegisterComponents('Samples', [tmybutton]);
RegisterPropertyEditor(TypeInfo(TAboutProperty), TMybutton, 'ABOUT', TAboutProperty);
end;
end.