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'
请解释一个问什么?
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'
请解释一个问什么?
解决方案 »
- 利用GDI+,将png图像转换为jpg图像时,如何设置png的透明背景色转换为jpg的白色背景色
- 如何实现图片加密?
- 播放器 可拖动的 进度条 如何 实现啊?
- 刚开始学delphi,很菜,请高手帮我看一下这段代码
- 输入框是一条线型,这是什么第三方控件还是tedit有这个属性?
- 求如下功能函数?
- fastreport分栏统计的问题!解决即揭贴!如果有解决方法,分不够还可以加。
- 请问哪里有DELPHI开发人员指南的附书源代码?
- 更改,add,delete数据库字段名,数据库类型为delphi自带的那种,扩展名是.db。
- 请问怎样将Tmemo中的多行文本变为一行显示
- 如何截取一字符串的某字符后的字符串
- 浏览器如实现分页
TMyForm = class(TForm)
private
public
constructor Create(Owner: TComponent; x: Integer);overload;
end;
粘贴的时候不小心删了 ‘end;’再加上。其它不变。
begin
GlobalNameSpace.BeginWrite;
try
CreateNew(Owner);
finally
GlobalNameSpace.EndWrite;
end;
showmessage('construceedf');
end;
TMyForm = class(TForm)
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; TMyForm = class(TForm)//改到上面
{ Private declarations }
public
{ Public declarations }
end;
type ******************這加入就可以了
TMyForm = class(TForm)
private
public
constructor Create(Owner: TComponent; x: Integer);overload;
end;
代码就如同我前面贴的那样,但一点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.
的 overload 去掉,实际上不是重载 而是改写 我上面写的错le
不需要加上 override...
overload 是不能改成 override 的 很明显楼主重新写了构造函数 改成override
编译根本不能通过 override 只能用于先后两次声明格式完全相同的情况
楼主的错误在于把两个form 放在一个unit 里 这样在生成第2个窗体的时候必然会
使得资源不够用 建议楼主把TMyform 放到别的Form下(别的Unit下也是会发生资源不足的,只能new form )这样问题应该能得到解决
---新手的拙见 仅供参考
你没有看清楚吗?我是动态生成一个窗体.我觉得问题很简单,希望各位能试着自己
不管是改成OVERRIDE不是OVERLOAD.
我的代码可以编译过去,但一点击BUTTON就报错.
不知道各位是不是试过点那个 BUTTON.看看是什么情况.