不过做类很少要选折TFORM作为基类
***********************
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
tmyform = class(TComponent)
frm :tform;
firstbutton:tbutton;
constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
procedure show;
end;
implementation
{ tmyform }
constructor tmyform.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
frm:=TForm.Create(Application);
frm.AutoScroll:=false;
frm.Hide;
firstbutton := tbutton.create(nil);
firstbutton.parent := frm;
firstbutton.Left := 23;
firstbutton.Top := 90;
end;
procedure tmyform.show;
begin
frm.ShowModal;
end;
destructor tmyform.Destroy;
begin
frm.free;
firstbutton.Free;
inherited Destroy;
end;
end.
***************************
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,unit2;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
myfirstform:tmyform;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
myfirstform := tmyform.Create(self);
myfirstform.show;
end;
end.