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;  TMyForm = class(TForm)
  private
  public
    constructor Create(Owner: TComponent; x: Integer);overload; 
end;var
  Form1: TForm1;implementation{$R *.dfm}constructor TMyForm.Create(Owner: TComponent; x: Integer);
begin
  inherited Create(Owner);
  showmessage('construceedf');
end;procedure TForm1.Button1Click(Sender: TObject);
var
  my: TMyForm;
begin
  my := TMyForm.Create(nil,8);
  my.Caption := 'sss';
end;end.我的代码有什么问题,编译通过了,但一运行就报错。 
'resource TMyForm not Found'
请解释一个问什么?

解决方案 »

  1.   


      TMyForm = class(TForm)
      private
      public
        constructor Create(Owner: TComponent; x: Integer);overload; 
      end;
    粘贴的时候不小心删了 ‘end;’再加上。其它不变。
      

  2.   

    overload; 改为reintroduce;constructor TMyForm.Create(Owner: TComponent; x: Integer);
    begin
      GlobalNameSpace.BeginWrite;
      try
        CreateNew(Owner);
      finally
        GlobalNameSpace.EndWrite;
      end;
      showmessage('construceedf');
    end;
      

  3.   

    type
      TMyForm = class(TForm)
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;  TMyForm = class(TForm)//改到上面
      

  4.   

    GlobalNameSpace.BeginWrite;这是干什么用的:)
      

  5.   

    没有TMyForm类的资源文件(.dfm) ,我觉得TMyForm应该写在另一单元文件中
      

  6.   

    private
        { Private declarations }
      public
        { Public declarations }
      end;
    type  ******************這加入就可以了
      TMyForm = class(TForm)
      private
      public
        constructor Create(Owner: TComponent; x: Integer);overload; 
    end;
      

  7.   

    to 天使:
      代码就如同我前面贴的那样,但一点BUTTON就报错。说xxxxxxxx地址错误。
    代码停在ShowMessage那一行。我再贴一次:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    type
      TMyForm = class(TForm)
      private
      public
        constructor Create(Owner: TComponent; i: Integer);reintroduce;overload;
      end;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}constructor TMyForm.Create(Owner: TComponent;i: Integer);
    begin
      inherited Create(Owner);
      ShowMessage('sdfsd');
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      m: TMyForm;
    begin
      m := TMyForm.Create(nil,8);
      m.Show;
    end;end.
      

  8.   

    你要实现什么效果?再new个form不行吗?
      

  9.   

    无聊!不就是资源文件没找到吗??两个窗体,其中一个的资源文件*.dfm去哪里了?
      

  10.   

    一个语法错误 是不?constructor Create(Owner: TComponent; x: Integer);overload; -> override.... 弄清楚 重载 vs 改写...
      

  11.   

    constructor Create(Owner: TComponent; x: Integer);overload; 
    的 overload 去掉,实际上不是重载 而是改写 我上面写的错le
    不需要加上 override...
      

  12.   

    overload---》override其他的没看出什么错误
      

  13.   


    overload 是不能改成 override 的 很明显楼主重新写了构造函数 改成override
    编译根本不能通过 override 只能用于先后两次声明格式完全相同的情况
      楼主的错误在于把两个form 放在一个unit 里 这样在生成第2个窗体的时候必然会
    使得资源不够用 建议楼主把TMyform 放到别的Form下(别的Unit下也是会发生资源不足的,只能new form )这样问题应该能得到解决 
                                                 ---新手的拙见 仅供参考
      

  14.   

    to:木脸猫
      你没有看清楚吗?我是动态生成一个窗体.我觉得问题很简单,希望各位能试着自己
    不管是改成OVERRIDE不是OVERLOAD.
    我的代码可以编译过去,但一点击BUTTON就报错.
    不知道各位是不是试过点那个 BUTTON.看看是什么情况.