动态生成窗体,提示错误:新窗体资源找不到! ( 积分: 50 )

  • 主题发起人 主题发起人 kisssun
  • 开始时间 开始时间
K

kisssun

Unregistered / Unconfirmed
GUEST, unregistred user!
错误产生在MyForm:=TMyForm1.Create(Application);这行.
错误为"Resource TMyForm1 not found"!!!
不胜感激!
代码如下:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst, Buttons;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyForm1 = class(TForm)
private

public
{ Public declarations }
end;
var
Form1: TForm1;
implementation

{$R *.dfm}

Function MyInteger:Integer;
var
MyForm:TMyForm1;
begin
MyForm:=TMyForm1.Create(Application);
try
MyForm.BorderStyle := bsDialog;
MyForm.Caption :='XXX';
MyForm.Position := poScreenCenter;
MyForm.Width :=310;
MyForm.Height :=380;

Result:=1;
MyForm.ShowModal ;

finally
MyForm.free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var xxx:integer;
begin
xxx:=MyInteger;
showmessage(inttostr(xxx));
end;
end.
 
错误产生在MyForm:=TMyForm1.Create(Application);这行.
错误为"Resource TMyForm1 not found"!!!
不胜感激!
代码如下:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst, Buttons;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyForm1 = class(TForm)
private

public
{ Public declarations }
end;
var
Form1: TForm1;
implementation

{$R *.dfm}

Function MyInteger:Integer;
var
MyForm:TMyForm1;
begin
MyForm:=TMyForm1.Create(Application);
try
MyForm.BorderStyle := bsDialog;
MyForm.Caption :='XXX';
MyForm.Position := poScreenCenter;
MyForm.Width :=310;
MyForm.Height :=380;

Result:=1;
MyForm.ShowModal ;

finally
MyForm.free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var xxx:integer;
begin
xxx:=MyInteger;
showmessage(inttostr(xxx));
end;
end.
 
TMyForm1 = class(TForm)改成 TMyForm1 = class(TForm1)就行了
 
我就是不想用TMyForm1 = class(TForm1)或TMyForm1 = class(TForm)
 
接受答案了.
 
后退
顶部