一个动态创建窗体的奇怪问题,请各位高手指点迷津 ( 积分: 100 )

  • 主题发起人 主题发起人 liudaobin
  • 开始时间 开始时间
L

liudaobin

Unregistered / Unconfirmed
GUEST, unregistred user!
编译什么都通过了,可在运行到AboutBox:=TAboutBox.Create(Application);时,出现了这样一段文字:
project project2.exe raised exception class EResNotFound with message'resource TAboutBox notfound'.process stopped.use step or run to contiute

AboutBox是一个窗体变量,程序执行时动态创建窗体,程序原来一直都使用正常,突然这段代码就不能用了,但其它同样动态创建的窗体又没问题,真是个奇怪的问题,请各位高手指点指点迷津,先谢谢各位了。

创建窗体部分的代码:
procedure Operate(opName:TopEnu);
begin
case opName of
AddUser : EditForm:= TEditForm.Create(Application);
Query : QueryForm:=TQueryForm.Create(Application);
Calcu : CalcForm:= TCalcForm.Create(Application);
Stat : StatForm:= TStatForm.Create(Application);
Tip : if TipForm=nil then TipForm:= TTipForm.Create(Application);
Alter : AlterTableForm:= TAlterTableForm.Create(Application);
prin : PrintForm:= TPrintForm.Create(Application);
Aboutf : AboutBox:= TAboutBox.Create(Application);//就是这里有问题了
Config : FormConfig:= TFormConfig.Create(Application);
Regist : FormReg:= TFormReg.Create(Application);
ZCCfg : FormZC:= TFormZC.Create(Application);
Resume : ResumeForm:= TResumeForm.Create(Application);
end;
end;



Unit文件内容如下:
unit about;

interface

uses Windows, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, shellapi, jpeg;

type
TAboutBox = class(TForm)
Panel1: TPanel;
ProgramIcon: TImage;
ProductName: TLabel;
Version: TLabel;
Copyright: TLabel;
Comments: TLabel;
EmailLabel: TLabel;
Label1: TLabel;
Label2: TLabel;
OKButton: TButton;
procedure LabelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
end;


implementation

{$R *.dfm}

procedure TAboutBox.LabelClick(Sender: TObject);
var Linkstr:string;
begin
case (sender as TLabel).Tag of
1: Linkstr:='mailto:LiuDaoBin@Km169.net';
2: Linkstr:='Http://WWW.GZRCRX.COM';
end;
ShellExecute(handle,nil,Pchar(Linkstr),nil,nil,SW_SHOWNORMAL);
end;

procedure TAboutBox.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WndParent :=0;
end;

end.

DFM文件内容如下:
object AboutBox: TAboutBox
Left = 449
Top = 278
BorderStyle = bsDialog
Caption = 'AboutBox'
ClientHeight = 214
ClientWidth = 298
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsMDIChild
OldCreateOrder = False
Position = poScreenCenter
Visible = True
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 8
Top = 8
Width = 281
Height = 161
BevelOuter = bvLowered
TabOrder = 0
object ProgramIcon: TImage
Left = 8
Top = 8
Width = 89
Height = 89
IsControl = True
end
object ProductName: TLabel
Left = 104
Top = 16
Width = 121
Height = 13
AutoSize = False
Caption = #20154#20107#26723#26696#31649#29702#31995#32479
Transparent = True
IsControl = True
end
object Version: TLabel
Left = 168
Top = 32
Width = 95
Height = 13
Caption = 'Version 2.0.051001'
Transparent = True
IsControl = True
end
object Copyright: TLabel
Left = 8
Top = 120
Width = 129
Height = 13
AutoSize = False
Caption = 'Copyright 2005-2006'
IsControl = True
end
object Comments: TLabel
Left = 8
Top = 139
Width = 233
Height = 13
AutoSize = False
Caption = 'Comments '#27743#35199#30465#36195#24030#24066#20154#25165#20132#27969#20013#24515
Transparent = True
WordWrap = True
IsControl = True
end
object EmailLabel: TLabel
Tag = 1
Left = 112
Top = 101
Width = 153
Height = 13
Cursor = crHandPoint
AutoSize = False
Caption = 'E-mail: LiuDaoBin@km169.net'
Font.Charset = DEFAULT_CHARSET
Font.Color = 10485760
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label1: TLabel
Tag = 2
Left = 112
Top = 81
Width = 153
Height = 13
Cursor = crHandPoint
AutoSize = False
Caption = #32593#22336#65306'WWW.GZRCRX.COM'
Font.Charset = DEFAULT_CHARSET
Font.Color = 10485760
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label2: TLabel
Left = 112
Top = 58
Width = 129
Height = 13
AutoSize = False
Caption = #31995#32479#35774#35745#65306#21016#36947#25996
end
end
object OKButton: TButton
Left = 120
Top = 178
Width = 65
Height = 33
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 1
IsControl = True
end
end
 
编译什么都通过了,可在运行到AboutBox:=TAboutBox.Create(Application);时,出现了这样一段文字:
project project2.exe raised exception class EResNotFound with message'resource TAboutBox notfound'.process stopped.use step or run to contiute

AboutBox是一个窗体变量,程序执行时动态创建窗体,程序原来一直都使用正常,突然这段代码就不能用了,但其它同样动态创建的窗体又没问题,真是个奇怪的问题,请各位高手指点指点迷津,先谢谢各位了。

创建窗体部分的代码:
procedure Operate(opName:TopEnu);
begin
case opName of
AddUser : EditForm:= TEditForm.Create(Application);
Query : QueryForm:=TQueryForm.Create(Application);
Calcu : CalcForm:= TCalcForm.Create(Application);
Stat : StatForm:= TStatForm.Create(Application);
Tip : if TipForm=nil then TipForm:= TTipForm.Create(Application);
Alter : AlterTableForm:= TAlterTableForm.Create(Application);
prin : PrintForm:= TPrintForm.Create(Application);
Aboutf : AboutBox:= TAboutBox.Create(Application);//就是这里有问题了
Config : FormConfig:= TFormConfig.Create(Application);
Regist : FormReg:= TFormReg.Create(Application);
ZCCfg : FormZC:= TFormZC.Create(Application);
Resume : ResumeForm:= TResumeForm.Create(Application);
end;
end;



Unit文件内容如下:
unit about;

interface

uses Windows, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, shellapi, jpeg;

type
TAboutBox = class(TForm)
Panel1: TPanel;
ProgramIcon: TImage;
ProductName: TLabel;
Version: TLabel;
Copyright: TLabel;
Comments: TLabel;
EmailLabel: TLabel;
Label1: TLabel;
Label2: TLabel;
OKButton: TButton;
procedure LabelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
end;


implementation

{$R *.dfm}

procedure TAboutBox.LabelClick(Sender: TObject);
var Linkstr:string;
begin
case (sender as TLabel).Tag of
1: Linkstr:='mailto:LiuDaoBin@Km169.net';
2: Linkstr:='Http://WWW.GZRCRX.COM';
end;
ShellExecute(handle,nil,Pchar(Linkstr),nil,nil,SW_SHOWNORMAL);
end;

procedure TAboutBox.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WndParent :=0;
end;

end.

DFM文件内容如下:
object AboutBox: TAboutBox
Left = 449
Top = 278
BorderStyle = bsDialog
Caption = 'AboutBox'
ClientHeight = 214
ClientWidth = 298
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsMDIChild
OldCreateOrder = False
Position = poScreenCenter
Visible = True
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 8
Top = 8
Width = 281
Height = 161
BevelOuter = bvLowered
TabOrder = 0
object ProgramIcon: TImage
Left = 8
Top = 8
Width = 89
Height = 89
IsControl = True
end
object ProductName: TLabel
Left = 104
Top = 16
Width = 121
Height = 13
AutoSize = False
Caption = #20154#20107#26723#26696#31649#29702#31995#32479
Transparent = True
IsControl = True
end
object Version: TLabel
Left = 168
Top = 32
Width = 95
Height = 13
Caption = 'Version 2.0.051001'
Transparent = True
IsControl = True
end
object Copyright: TLabel
Left = 8
Top = 120
Width = 129
Height = 13
AutoSize = False
Caption = 'Copyright 2005-2006'
IsControl = True
end
object Comments: TLabel
Left = 8
Top = 139
Width = 233
Height = 13
AutoSize = False
Caption = 'Comments '#27743#35199#30465#36195#24030#24066#20154#25165#20132#27969#20013#24515
Transparent = True
WordWrap = True
IsControl = True
end
object EmailLabel: TLabel
Tag = 1
Left = 112
Top = 101
Width = 153
Height = 13
Cursor = crHandPoint
AutoSize = False
Caption = 'E-mail: LiuDaoBin@km169.net'
Font.Charset = DEFAULT_CHARSET
Font.Color = 10485760
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label1: TLabel
Tag = 2
Left = 112
Top = 81
Width = 153
Height = 13
Cursor = crHandPoint
AutoSize = False
Caption = #32593#22336#65306'WWW.GZRCRX.COM'
Font.Charset = DEFAULT_CHARSET
Font.Color = 10485760
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label2: TLabel
Left = 112
Top = 58
Width = 129
Height = 13
AutoSize = False
Caption = #31995#32479#35774#35745#65306#21016#36947#25996
end
end
object OKButton: TButton
Left = 120
Top = 178
Width = 65
Height = 33
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 1
IsControl = True
end
end
 
可能是delphi本身的bug,先把about单元remove,然后再加一次
 
可能是你的 about.dfm 文件弄丢了!
 
songjy:
我一开始也是这样认为,而且试着把窗体重做了,可还是报这个错误
to 乖乖兔:
在Delphi里看这个窗体又没问题,应该不是about.dfm文件丢失了
 
问题解决了,原来是我创建了中文资源,这个窗体不知为什么没有导入[:(],把文件project2.dpr中的{$R *.RES}这一句去掉就OK了[:D]
谢谢songjy和乖乖兔对我问题的关注,虽然没有帮我解决问题,也给每人20分的关注分吧[^][:D]
 
?????????结不了帖??????奇怪了?????[:(]
 
哦,是不分配的分数与总分数不一样,那就每人给50吧~~~[:)]
 

Similar threads

后退
顶部