请给出原因和解答unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  Tfrm = class(TForm)
  private
    FParentRect: TRect;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property ParentRect: TRect read FParentRect write FParentRect;
  end;  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  Ffrm: Tfrm;implementation{$R *.dfm}constructor Tfrm.Create(AOwner: TComponent);
begin
  inherited;
end;destructor Tfrm.Destroy;
begin
  inherited;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  if not Assigned(Ffrm) then
  begin
    Ffrm := Tfrm.Create(self);
    Ffrm.Parent := self;
  end;
  Ffrm.Show;
end;end.

解决方案 »

  1.   

    错误提示:
    Resource Tfrm not found.
      

  2.   

    Delphi的窗体控件是和编译器结合在一起的,必须要有资源文件,即.dfm文件,你的Unit1.dfm文件中只有TForm1的资源,所以出错,而且不能把2个窗体控件定义在1个单元文件中,必须分开定义,然后调用。
      

  3.   

    怎么在同一个单元里面定义了两个窗口类,没听说过可以这样做的
    你把Tfrm和TForm1的定义分别放在单独的一个单元里面,然后在TForm1所在的Unit里面uses Tfrm所在的Unit。
      

  4.   

    因为你的窗体文件没有dfm文件,所以就不行啦,呵呵
      

  5.   

    你既然是测试例子,那这样就可以,你自己想想
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;  Tfrm = class(TForm1)
      private
        FParentRect: TRect;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        property ParentRect: TRect read FParentRect write FParentRect;
      end;
    var
      Form1: TForm1;implementation{$R *.dfm}constructor Tfrm.Create(AOwner: TComponent);
    begin
      inherited;
    end;destructor Tfrm.Destroy;
    begin
      inherited;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Ffrm: Tfrm;
    begin
      Ffrm := Tfrm.Create(nil);
      Ffrm.Left := 100;
      Ffrm.Top := 100;
      Ffrm.Parent := self;
      Ffrm.Show;
    end;end.