★我在用一个窗体调用另一个窗体时出现下面的错误,如何解决?(200分)

  • 主题发起人 volcanosh
  • 开始时间
V

volcanosh

Unregistered / Unconfirmed
GUEST, unregistred user!
★我在用一个窗体调用另一个窗体时出现下面的错误,如何解决?
Degugger Exception Noticfication
Project Project1.exe raised exception class Eaccessviolation with message
'Access Violatin at address 00465EB3 in module 'Project1.exe',
Read of Adress 00000000,Process stopped. Use Step or Run to continue.
 
可能是对象创建的问题,要看代码才行
 
要看哪一段?
 
当然看调用的那一段,
你的窗体是动态创建的吗?
 
代码贴出来啊
 
procedure TForm1.spdFixClick(Sender: TObject);
begin
frmfixie.showmodal;
end;
上面这段没错吧?
是下面这段?
program Project1;
uses
Forms,
ieArmor in 'ieArmor.pas' {Form1},
fixie in 'fixie.pas' {frmFixie};

{$R *.res}

begin
Application.Initialize;
Application.Title := 'IE超级装甲';
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
 
unit fixie;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, CheckLst,registry, Buttons;

type
TfrmFixie = class(TForm)
clbOption: TCheckListBox;
btnSelAll: TBitBtn;
btnNoSel: TBitBtn;
btnFix: TBitBtn;
ListBox1: TListBox;
btnWin: TButton;
btnIeTool: TButton;
btnRight: TButton;
btnDel: TButton;

procedure btnFixClick(Sender: TObject);
procedure btnSelAllClick(Sender: TObject);
procedure btnNoSelClick(Sender: TObject);
procedure btnWinClick(Sender: TObject);
procedure btnIeToolClick(Sender: TObject);
procedure btnRightClick(Sender: TObject);
procedure btnDelClick(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
frmFixie: TfrmFixie;
regName:string;

implementation

{$R *.dfm}



unit ieArmor;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls, Buttons,shellapi,registry;

type
TForm1 = class(TForm)
imgNoarmor: TImage;
spdStart: TSpeedButton;
image1: TImage;
spdHome: TSpeedButton;
spdEmail: TSpeedButton;
spdExit: TSpeedButton;
spdArmor: TSpeedButton;
spdClose: TSpeedButton;
imgArmor: TImage;
spdFix: TSpeedButton;
procedure btnExitClick(Sender: TObject);
procedure spdExitClick(Sender: TObject);
procedure spdHomeClick(Sender: TObject);
procedure spdEmailClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure spdArmorClick(Sender: TObject);
procedure spdFixClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
noArmor:boolean;

implementation

uses Unit2, fixie;



{$R *.dfm}




 
我就是先加入了很多窗体,后来又把它们删除了。会不会是它们留下了什么东西?
 
不会
但是在窗体 Showmodal之前应该先创建
frm := Tfrm。create(application);
try
frm.showmodal;
finally
frm.free;
end;
 
呵呵,
Application.Title := 'IE超级装甲';
Application.CreateForm(TForm1, Form1);
Application.Run;
这段开发可以看出你的这个窗体是动态创建的
和楼上观点一样
所以要
frmfixie:=TFrmFixie.create(Application);
try
frmfixie.showmodal;
finally
frmfixie.free;
end;
 
从提示上看是存取了一个不存在的对象,看窗体是否创建。
 
我找到原因了——在options中把要调用的窗体删除了
 
多人接受答案了。
 
顶部